Rasmus’ tips for ARM Cortex-M energy efficiency #2.
Rasmus is a Support & Training manager at Energy Micro, supporting customers with technical articles, seminars, and video materials. He also operates “The Lizard Lounge” forum open to everyone to share engineering ideas and application design tips.
In a series of posts on the Energy Micro blog, I´ll take a closer look at some of the features that are available for ARM Cortex-M microcontroller users. I will also show you some examples how I normally use them, and how they can be helpful when trying to reduce the energy consumption in embedded applications.
The ARM Cortex-M Nested Vector Interrupt Controller, NVIC, includes a feature called Sleep-on-Exit which helps save CPU cycles and energy. This is a very useful feature if you develop an application where most of the work is done in interrupt handlers with periods of sleeping between interrupt events.
When your processor enters an Interrupt Service Routine (ISR), the state of the regular thread needs to be pushed to the stack, and then un-stacked when returning from the ISR. When a regular MCU is only going to sleep after an ISR, the state still needs to be unstacked before the thread code can put the device to sleep. When the next interrupt wakes the device up, the state again needs to be stacked.
When I work with the EFM32 ARM Cortex-M based microcontrollers, my application can put the MCU to sleep mode directly after the ISR without returning to the thread. As the state was never unstacked, it does not need to be stacked again when waking up. Therefore, this technology eliminates both the stacking and unstacking cycles, as well as any code that normally has to put the device to sleep. So as you can see, I get a cleaner application execution, with fewer cycles used for non-application tasks, and less energy wasted as the result.
Read more about Sleep-on-Exit here: Using the Sleep-on-Exit Feature
Learn about how the EFM32 microcontrollers maximize time in sleep mode: http://www.energymicro.com/technology/
Any technical questions? Find your answer on our forum!