introduction
Many embedded developers are familiar with the ARM Cortex processor architecture, but few are able to fully understand this popular architecture and take advantage of its unique features and performance. This is especially true of the new ARM Cortex-M4 processor, which boasts an enhanced architecture, native digital signal processing (DSP) capabilities, and an optional floating-point accelerator that allows programmers or hardware engineers who are skilled in this field to take full advantage of it. The rest of this article will detail some of the more interesting (but often overlooked) features of the Cortex-M3/M4 microcontroller (MCU).
Most of the target applications using Cortex-M3/M4 MCUs are portable and powered by batteries or energy harvesting systems, so most of the concepts we discuss involve techniques to reduce the overall energy consumption of the system. However, in many cases, these energy-saving techniques are also powerful tools in processor application design, providing:
●More cost-effective solution
● Greater design redundancy for upgrades and adoption of new features
●Performance and features that help products stand out in a competitive market
Basic Introduction to ARM Cortex
Like the first generation of 16-bit processor cores introduced by Advanced RISC Machines (ARM) in the 1980s, the ARM Cortex family is based on the Harvard RISC architecture, using a modest silicon packaging process to achieve higher performance, as well as code and memory efficiency. The architecture has evolved significantly over the past decade, expanding into three different sub-families to meet the needs of specific applications:
●A series processors are optimized for high-performance open application platforms.
●R series processors focus on improving the performance and reliability of real-time applications.
The M-series processors are specifically designed for applications using embedded MCUs, where performance must be balanced between energy efficiency and reducing solution costs. Common applications for the Cortex M series include smart meters, human-machine interface devices, automotive and industrial control systems, white appliances, consumer electronics, and medical devices.
Cortex-M3 vs Cortex-M4
The guiding idea behind the Cortex-M3 architecture was to design a processor that would provide high performance computing and control1 for applications that were cost-effective. Such applications include automotive body systems, industrial control systems, and wireless networking/sensor products. The M3 family introduces several key features to the 32-bit ARM processor architecture, including:
Non-maskable interrupt
●Highly deterministic, nested, vectored interrupts
●Atomic bit manipulation
●Optional storage protection (MPU)
In addition to excellent computational performance, the Cortex-M3 processor's advanced interrupt structure ensures that the system responds quickly to real-world events while still providing extremely low dynamic and static power consumption2.
Figure 1: Comparison of the Cortex-M3 and M4 processor cores.
The Cortex-M3 and M4 processors share many of the same design elements, including advanced on-chip debugging features, and the ability to execute the full ARM instruction set or a subset of the ARM instruction set (for THUMB2 processors). The Cortex-M4 processor's instruction set has an enhanced library of efficient DSP features, including an extended single-cycle 16/32-bit multiply-accumulator (MAC), dual 16-bit MAC instructions, optimized 8/16-bit SIMD operations, and saturation operation instructions. Overall, the most significant difference between the M3 and M4 is that the M4 has an optional single-precision (IEEE-754) floating-point unit (FPU).
Several secrets lead to a clever solution
The success or failure of embedded designs often depends on how to find the right balance between system performance, energy consumption and solution cost. In many cases, developers can use the unique features of the Cortex-M processor to optimize product cost or energy requirements while maintaining or even improving its performance. For example, the Cortex-M core's native serial I/O capabilities can be used to save energy, simplify development, and free up peripherals for other application tasks.
In addition to the traditional Serial Wire Debug functionality, ARM Cortex-M based MCUs can also provide an instruction trace interface through its single pin Serial Wire Viewer Output (SWO)3, as shown in Figure 2. This interface can pass “printf format” debug information directly to the application code. SWO allows debug information to be viewed directly in any standard IDE. In addition, this information can also be viewed using a standalone SWO monitor (for example, Segger’s J-Link SWO Viewer software4, or Silicon Labs’ energyAware Commander 4). Since the SWO output is built into the core hardware itself, it is an inherent advantage of the Cortex-M core. SWO does not occupy any UART interfaces of the MCU, which may have already been allocated to the application.
Figure 2: Dedicated ARM Cortex SWO interface saves I/O pins and speeds up debugging.
Another important advantage of SWO-based debugging is that it allows the microcontroller to maintain a valid debug connection when entering the lowest sleep mode, while in most cases, traditional debug connections will not work properly at this time. SWO's instruction trace can also be used to track the program counter to help the IDE count the time taken by various functions of the program. These statistics can be combined with current measurements to help developers fine-tune the design power consumption.
Vendors of Cortex-M-based microcontrollers are beginning to recognize this benefit, and some have already incorporated power mode and current measurement hardware into their development platforms for this purpose. For example, Silicon Labs' EFM32 Gecko MCU entry-level and development-level kits include power measurement outputs that can be used in conjunction with the program code tracing capabilities in the energyAware Profiler tool6. Figure 3 shows how this allows designers to pinpoint which program function blocks are consuming the most energy and quickly debug other energy-related issues. [page]
Figure 3: Hardware and software tools pinpoint the functions consuming the most energy, eliminating the need for oscilloscopes and multimeters, and enabling quick troubleshooting.
Smart sleep saves every microwatt
The Sleep-on-Exit feature of the ARM Cortex-M processor is another feature that "kills two birds with one stone" and saves CPU cycles and energy consumption at the same time. This is particularly useful in interrupt-driven applications because the processor spends most of its time either executing interrupt processing or sleeping between interrupt events. When entering the interrupt service routine (ISR), the MCU must spend several instruction cycles to push the current thread state into the stack, and then restore the original thread state when exiting the interrupt processing, that is, "pop the stack." When the application requires the processor to enter the sleep state directly after exiting the ISR, the traditional MCU must still restore the previously stored state information before the thread code can put the MCU to sleep. Similarly, when the next interrupt wakes up the MCU, its state must be pushed into the stack again.
When the Sleep-on-Exit feature is enabled on an ARM Cortex-M microcontroller, the MCU goes directly to sleep after the interrupt is processed, without returning to the original thread first (see Figure 4). This keeps the processor in the interrupt state, saving valuable machine cycles by eliminating the wake-up and stack push process. Eliminating the stack push and pop process saves both time and energy, which would otherwise be wasted by unnecessary instruction cycles, including the code that manages the stack between sleep and wakeup in traditional MCUs. Furthermore, when the processor is woken up by a Halt Debug Request, the stack pop process is automatically performed.
Figure 4: The Sleep-on-Exit feature of the ARM Cortex-M reduces power consumption by avoiding unnecessary code execution and reducing stack pop and stack operations. (Source: The Definitive Guide to the ARM Cortex-M31)
ARM Cortex-M4 runs faster and consumes less power in sleep mode
Like many MCUs, the Cortex-M3/4 processors are often able to use high clock rates to save power in interrupt-driven applications. This seemingly counterintuitive but commonly used power-saving strategy works well if the processor spends most of its time asleep, because the power savings from reduced run time far outweigh the slightly higher operating current. In simple terms, spending 10% more power can save 20% of the time, which is an overall power saving.
This technology can be applied to any Cortex-M series processor, and applications involving intensive computing tasks can also benefit from the additional power of the Cortex-M4 processor. Its single-cycle DSP instructions and optional floating-point accelerator can significantly reduce the number of execution cycles required for functions such as digital signal processing, filtering, analysis or waveform synthesis.
Some applications simply require DSP processing power. For example, some security systems use a device that uses acoustic analysis to sense glass breakage. When glass is broken, it emits a unique series of sounds and vibrations that are maximized at a natural frequency that is unique to glass, in this case 13kHz. Most systems that use sensor interfaces will only wake up the processor when the monitored frequency is detected. However, when the Cortex-M4 with DSP capabilities is used in the design, additional power savings can be achieved because it can perform the actual glass breakage analysis faster than software solutions.
Even these applications using M4-based microcontrollers can be more energy efficient, as the advanced sleep modes and autonomous peripherals included in the MCU can perform many routine tasks while the CPU is asleep. For example, the Wonder Gecko MCU7 with Cortex-M4 as the core has five different low-power modes, including a 20nA shutdown state and a 950nA deep sleep mode (real-time clock active, RAM and register contents retained, brownout detection enabled).
The energy-saving features mentioned above can also bring other advantages. For example, in applications such as ultrasonic/acoustic water meters, they must run for many years on a small battery, requiring the MCU to remain in sleep mode as long as possible. In addition to helping reduce the MCU wake-up time, the Cortex-4 DSP and floating-point arithmetic instructions can also use sophisticated filtering functions to obtain the required information from the output of inexpensive acoustic sensors, thereby avoiding the use of expensive ultrasonic flow sensors. In this application example, the peripherals of the Wonder Gecko MCU can also provide additional energy savings as an analog state machine, which wakes up the Cortex-M4 processor only when needed.
in conclusion
While not exhaustive, these various tips and tricks should give you a good idea of how to take advantage of some of the lesser-known features of the Cortex-M series in your next design. To take advantage of these and other important features of the ARM Cortex-M series, the references at the end of this article provide the additional details you need.
In addition, the EFM32 Gecko and Wonder Gecko MCU families from Silicon Labs provide excellent examples of how to improve design performance, power consumption and solution cost by choosing an ARM MCU with the right I/O, accelerators and other advanced peripherals.
Previous article:Application of Data Fusion Technology in Vehicle Dynamic Weighing System
Next article:Design of Adaptive Headlight System for Embedded Systems
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Fast multiplexing within and between boards
- vl813 schematic diagram solution sharing
- Metal detector circuit diagram design
- Design of scalable modular multiplication operator with base 4.pdf
- Package size issue
- What are the changes in the maximum output current and load limit of a differential output amplifier when it is single-ended output?
- Get a sneak peek at the practical white paper "Harnessing the Power of 5G"!
- How to write C/C++ code in DSP?
- 70Mpa High-pressure Hydrogen Fuel Vehicle Filling Station Overall Solution
- 【CH579M-R1】+ driving LCD19264 display