Achieving near-determinism in microcontrollers with cache and on-chip flash

Publisher:泉趣人Latest update time:2012-01-30 Source: 今日电子 Keywords:Cache Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In order to control the actuator, the real-time control system receives input signals from sensors and outputs command signals to the actuator after control operations. These outputs must be triggered within a specified time after receiving the input - that is, the system must have real-time performance; at the same time, for the same input under the same control state, the output should always be the same - that is, the system must be deterministic.

Developments in many areas of the electronics industry are making these basic real-time control systems increasingly complex. On the one hand, control algorithms are becoming more sophisticated, reaching the level of artificial intelligence in decision-making. On the other hand, these control systems are increasingly connected to the Internet, both locally via Ethernet or wireless local area networks (LANs) and over long distances via the Internet. In addition, user interfaces are becoming increasingly complex and security requirements are becoming increasingly stringent, making data encryption and verification of the legitimacy of external control sources essential system features.

These trends require processors with more powerful processing power and higher communication bandwidth. The processor must be able to respond to real-time input signals in a certain way, and there must be enough memory to handle various network communications as a low-priority task. However, in many cases, system upgrades for improved performance require retaining the original device drivers, network protocol stacks, and some basic operations that serve as the basis for control algorithms. This is especially true when using industry-standard processor architectures, such as 32-bit ARM RISC. Figure 1 shows an example of an MCU upgrade that follows these two principles, that is, upgrading from the ARM7-based AT91SAM7X series to the ARM9-based AT91SAM9XE series. Both series of devices have on-chip flash memory for storing program code and reference data.

One important difference between the two families is that the ARM9 processor has instruction and data caches, while the ARM7 processor does not. Caches help mitigate the performance degradation caused by the difference in capabilities between the processor and memory (the former can run code at about 200MIPS, while the latter can only transfer data at about 25MHz). It is well known that it is impossible to achieve complete determinism in a system using caches. However, many architectural features of the ARM926EJ-S processor and AT91SAM9XE microcontroller family allow application developers to achieve near-deterministic real-time performance.

High-speed cache + wide data bus on-chip flash memory

Many architectural features can maximize the internal data transfer bandwidth. As shown in Figure 2, taking the AT91SAM9XE series as an example, in addition to having separate 16Kb instruction and data caches that can operate at processor speed, a 7-layer AHB bus matrix is ​​used to establish parallel data channels between the processor, peripherals, and memory. The USB host and Ethernet MAC peripherals have dedicated DMA ports to achieve autonomous data transfer, while their APB peripherals are equipped with a peripheral DMA controller (PDC), so that bulk data transfers between memory and network interfaces occupy almost no processor resources. The Advanced Interrupt Controller (AIC) can handle a series of priority interrupt vectors within a specified number of processor cycles.

Figure 1 AT91SAM7X series upgraded to AT91SAM9XE series

Figure 2 AT91SAM9XE architecture

The cache enables the processor to obtain instructions and data in a timely manner at the speed it requires, unless the required data or instructions are not buffered in the cache. In this case, the processor has to idle for a while until the cache is refilled. The highly parallel DMA data transfer mechanism can reduce the processor's intervention in data transfer, but it is not completely non-involved. Because interrupt requests may occur at any time, even if only a few cycles are needed to process the interrupt. So how can we ensure that the system triggers a certain output based on a given input within the specified time?

How to get certainty

To achieve determinism, the code for each critical operation stored in flash memory can be broken down into modules less than 16Kb. The required module is loaded into the instruction cache and locked to ensure that it is always in the cache during the execution of the module. If necessary, the related data structures can also be loaded and locked in the data cache. Here, the latching function is implemented by the latch register of the cache. This ensures that the critical code is executed at the speed of the processor.

If a cache does not have the required instruction code, the cache will reload the required instruction code through the 128-bit data bus between it and the on-chip flash memory. The bus can load 32-bit data at 4 times the processor clock speed, greatly reducing the time to refresh the cache. In addition, the cache's wrapping function ensures that missed critical data is loaded first.

Taking all these factors into account, calculating the execution time, and making the worst-case scenario for multiple interrupts and DMA transfers at the same time, you can determine whether the real-time constraints can be met and with what margin. If necessary, you can also write some fallback procedures for each possible situation, allowing the system to run in a fail-soft mode (that is, a reliable but reduced performance mode) when the real-time requirements cannot be met.

in conclusion

Careful design of the application code to take advantage of the key architectural features of the processor core will enable near determinism in embedded connected real-time control systems based on complex control algorithms. These key architectural features include: data and instruction cache latching, wraparound capabilities, a 128-bit wide data bus connecting the cache to the on-chip flash memory, a low-latency advanced interrupt controller, and a DMA controller for direct data transfers between peripherals, network interfaces, and on-chip/off-chip flash memory.

Keywords:Cache Reference address:Achieving near-determinism in microcontrollers with cache and on-chip flash

Previous article:Using Eclipse IDE technology to speed up MCU design
Next article:How to reliably start the DS1302 clock chip

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号