The ARM Cortex-M4 processor offers various low power modes to reduce power consumption during periods of inactivity. By leveraging these low power modes, Cortex-M4 based microcontrollers can operate for extended periods on battery power. The main low power modes available in Cortex-M4 are Sleep, Deep Sleep, and Stop modes.
Sleep mode is the lowest power mode in Cortex-M4. In this mode, the CPU, deep sleep domain peripherals, and system clock are turned off to save power. However, SRAM and register contents are retained, allowing for quick wake up and resume. The wake up latency is around 3 clock cycles.
To enter sleep mode, the WFI (Wait For Interrupt) instruction can be executed. This will cause the processor to suspend execution and enter sleep until an interrupt occurs to wake it up. Alternatively, the SLEEPONEXIT bit can be set in the System Control Register. This will make the processor enter sleep mode automatically whenever it exits an ISR.
In sleep mode, asynchronous modules like watchdog timer, RTC, and GPIO can remain active to wake up the system when needed. Low power peripherals like LP timers and wakeup controller also stay powered on. SRAM can be put into retention or powered down depending on requirements. With proper configuration, sleep mode currents can be as low as 9uA per MHz.
Deep Sleep Mode
Deep sleep mode offers lower current consumption than sleep mode. It is very similar, but has the additional capability to power down the core voltage regulator and cut power to the logic. This reduces both active leakage and standby current.
To use deep sleep, the DEEPSLEEP bit must be set in the System Control Register. The processor then executes WFI to enter deep sleep. All SRAM contents are still retained. Wakeup latency is higher than sleep mode at around 5us.
In deep sleep, the low power peripherals stay powered like LP timer, RTC, I/O etc. Flash can also be disabled if not needed. External oscillator like crystal oscillator stops during deep sleep. The net result is very low power consumption, in the range of 2-3uA per MHz.
Stop mode is the lowest power mode in Cortex-M4 with complete system shut down. In stop mode, the core voltage regulator and all clocks are disabled. This removes power from the CPU, memories, and peripherals. The voltage regulator standby mode is also activated to minimize power.
To use stop mode, the STOP bit must be set in the System Control Register. The processor must then execute the WFI instruction. This will shut down all power and clocks. Wake up from stop mode can be initiated by resets or enabled wakeup events.
Since power is fully removed in stop mode, SRAM and register contents are lost. So these must be saved in retention registers or external low power memory before entering stop mode. On wakeup, the context has to be restored which impacts latency. Typical wakeup times are around 5us.
With everything shut down, the stop mode current can be just a few uA. Only a real-time clock or external wakeup events can be used to transition back to active mode. Due to the higher entry/exit overhead, stop mode is best used when longest inactive periods are expected.
Factors that Impact Power Consumption
While the above modes provide various degrees of power savings, actual currents consumed depend on multiple factors:
- System clock frequency – Higher clocks generally consume more power
- Voltage levels – Lower core and I/O voltages reduce power
- Peripheral activity – More active peripherals and I/O results in higher currents
- SRAM Usage – Retaining or powering down SRAM affects sleep/deep-sleep mode power
- Process technology – Smaller geometry process nodes have lower leakage
So while developing low power Cortex-M4 applications, architects must consider optimizing these aspects in addition to utilizing the low power modes effectively. Multiple power domains with independent control allow unnecessary logic to be powered down when not required.
Wakeup from Low Power Modes
As the processor and system are dormant during low power modes, external events are needed to trigger wakeups. There are multiple ways low power Cortex-M4 MCUs can be woken up, including:
- External interrupts from GPIO pins
- Internal peripheral interrupts like RTC, watchdog timer etc
- Configured wakeup pins changing state
- Reset signals from external sources
- Debug subsystem activity like breakpoints, watchpoints etc
These wakeup events are enabled using the NVIC and wakeup controller registers in the Cortex-M4 system. When enabled events occur, the processor will exit low power and resume normal operation. With multiple wakeup options, flexibility is provided to exit low power modes based on diverse system needs.
Software Flow for Low Power Operation
The following represents a typical software flow to make effective use of Cortex-M4 low power modes:
- Identify idle periods in application loop when processor can go into low power mode.
- Determine which low power mode (sleep/deep-sleep/stop) is suitable based on idle time and wakeup latency constraints.
- Configure low power mode by setting appropriate bits in System Control Register.
- Enable interrupts or wakeup events that can transition processor from low power to active mode.
- Make sure important system state like SRAM contents are saved/restored around low power entry/exit.
- Insert WFI instruction in code to actually enter the low power mode.
- On wakeup from WFI, restore context and resume application tasks.
The Cortex-M4 processor also provides WFE (Wait For Event) instruction that works similarly for entering low power modes. The software considerations largely remain the same.
Benefits of Cortex-M4 Low Power Operation
Leveraging the low power modes in Cortex-M4 results in several benefits for embedded systems:
- Greatly reduced power consumption to extend battery life.
- Lower energy usage with lower operating costs.
- Compact system designs without bigger batteries or power sources.
- Efficient operation in energy harvesting systems.
- Ability to manage multiple power modes with independent wake events.
- Flexibility to tailor power savings versus wakeup latency as per use case.
With these power saving modes and intelligent software usage, Cortex-M4 MCUs enable designers to create high performance embedded systems with extended battery operation and ultra low energy profiles.