Sleep, Stop and Standby Modes Explained for Cortex-M
Sleep, Stop and Standby are the three usual low-power modes on a Cortex-M microcontroller. Learn what each one turns off, what it keeps and how it wakes.

A microcontroller that runs from a coin cell for a year spends nearly all of that time doing nothing. The skill in low-power firmware is making "nothing" cost almost no current, and the chip gives you a ladder of low-power modes to climb down. The ladder has three rungs that nearly every vendor offers under similar names: Sleep, Stop and Standby. Each rung switches off more of the chip, saves more current and takes longer to wake from. This post explains what the three modes mean, which part comes from the Arm core and which from the vendor, what survives in each, and how a program leaves one. It uses an STM32F411 (Cortex-M4) as the concrete example, and the register and bit names come from RM0383, the reference manual, and from the Cortex-M4 Devices Generic User Guide for the core part. The code compiles with arm-none-eabi-gcc 13.3 against CMSIS device headers.
Two layers: the core and the chip
The Arm architecture defines only two things. The first is a pair of instructions that stop the core, WFI (wait for interrupt) and WFE (wait for event). The second is a bit in the System Control Register, SCB->SCR, called SLEEPDEEP. When the core executes WFI with SLEEPDEEP clear, it enters sleep, which means the core stops fetching instructions and the processor clock can be gated. With SLEEPDEEP set, it enters deep sleep, which gives the chip permission to gate more, and the chip's own power controller decides how much.
Everything below the core is the vendor's design. Names such as Stop and Standby come from STMicroelectronics. Other vendors use different words for similar ideas: Silicon Labs has EM1, EM2, EM3 and EM4, Nordic has System ON idle and System OFF, and NXP has Wait, Stop and Power-down. The mapping to the Arm bit is the same everywhere: shallow modes keep SLEEPDEEP clear and deep ones set it.
The three modes on an STM32F4
Sleep. The CPU clock stops. Every peripheral clock, the flash, the SRAM and the regulators stay on, so any interrupt wakes the core at once. This is the easiest mode to use because nothing about the chip's state changes. The saving is only the core's own consumption, which is a fraction of the total at a high clock.
Stop. The clocks of the 1.2 V domain are stopped: the PLL, the high-speed oscillators and all the peripheral clocks that depend on them. The SRAM and the registers keep their contents, because the regulator keeps powering them, in a main or low-power mode. The chip sits at a low current, and the program resumes after the instruction that entered Stop, on the internal HSI oscillator, so the clock tree must be set up again. Wake-up sources are the EXTI lines, which include GPIO pins and the RTC alarm and wake-up timer.
Standby. The 1.2 V regulator is switched off. SRAM and the registers lose their contents, except the backup domain: the RTC, the backup registers and the optional backup SRAM, which is powered from VBAT or VDD. The lowest current of the three, and the longest wake-up, because wake-up is a reset. After waking, the code starts from the reset vector, and the program checks a flag to learn that it woke from Standby and not from power-on.
The ST reference manual's power section gives the entry method and the wake-up sources for each, and the table below summarises it for the F411:
| Sleep | Stop | Standby | |
|---|---|---|---|
| Core | Stopped | Stopped | Off |
SLEEPDEEP | 0 | 1, PDDS = 0 | 1, PDDS = 1 |
| Peripheral clocks | Running | Stopped | Off |
| SRAM and registers | Kept | Kept | Lost, except backup domain |
| Wake-up | Any enabled interrupt | EXTI line, RTC alarm and wake-up | WKUP pin, RTC alarm, NRST, IWDG |
| Resumes | After the WFI | After the WFI, on HSI | At reset |
| Typical use | Idle between events | Seconds to hours between events | Minutes to days between events |
PDDS is the "power-down deepsleep" bit in PWR->CR. It selects between Stop (0) and Standby (1) when SLEEPDEEP is set.
Entering each mode in code
Sleep is a single instruction:
#include "stm32f4xx.h"
void enter_sleep(void)
{
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; // shallow sleep
__WFI(); // core stops until an interrupt
}Stop adds the SLEEPDEEP bit and clears PDDS:
void enter_stop(void)
{
RCC->APB1ENR |= RCC_APB1ENR_PWREN; // PWR registers need their clock
PWR->CR &= ~PWR_CR_PDDS; // Stop, not Standby
PWR->CR |= PWR_CR_LPDS; // low-power regulator in Stop
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFI();
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; // so later __WFI calls only sleep
}Standby sets PDDS and must clear the wake-up flag first, or the chip leaves Standby straight away:
void enter_standby(void)
{
RCC->APB1ENR |= RCC_APB1ENR_PWREN;
PWR->CR |= PWR_CR_CWUF; // clear the wake-up flag
PWR->CSR |= PWR_CSR_EWUP; // enable the WKUP pin (PA0)
PWR->CR |= PWR_CR_PDDS; // Standby
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFI(); // never returns
}After a Standby wake-up the chip resets, so the next line the program executes is the start of main. Distinguish the cases with the standby flag:
int main(void)
{
RCC->APB1ENR |= RCC_APB1ENR_PWREN;
if (PWR->CSR & PWR_CSR_SBF) {
PWR->CR |= PWR_CR_CSBF; // clear the standby flag
// woke from Standby: restore state from backup registers
} else {
// first power-on
}
// ...
}cold boot: SBF = 0
after Standby: SBF = 1, cleared by CSBF, state restored from backup registersWhat you have to rebuild after Stop
Stop keeps RAM and registers, so variables are intact, but the clocks are not. The F411 restarts on the 16 MHz HSI oscillator after Stop. If the system ran from the PLL at 96 MHz before, every peripheral that depends on the old frequency, including the UART baud rate divider and timer prescalers, is now wrong until the clock is reconfigured. A typical first action after waking is to call the same clock setup function used at start:
void enter_stop_and_restore(void)
{
enter_stop();
SystemClock_Config(); // reselect HSE, PLL and flash wait states
}Forgetting this produces a baud rate that is wrong by a factor of six and garbled serial output, the classic symptom of "it works until it sleeps once".
Choosing a mode
The decision follows from three questions. How long will the chip sleep? A few microseconds to milliseconds favours Sleep, because wake-up is instant and nothing needs restoring. How much state must survive? If a lot of RAM state has to remain, Stop keeps it and Standby does not. How quickly must it respond? Stop resumes in a few microseconds to tens of microseconds of oscillator start-up, per the datasheet, and Standby takes longer because it goes through a reset and start-up code.
A rough rule: sleep when idle for less than about a millisecond, Stop for periods up to hours when you need RAM, Standby when the interval is long enough that the energy saved beats the cost of restoring state. The break-even point is an arithmetic question about charge. The extra current of Stop over Standby times the sleep time, against the charge spent re-initialising after Standby, decides it, and the datasheet's current table gives you both inputs.
What can go wrong
The core wakes up at once. A pending interrupt, even one you did not expect, wakes the core immediately.
WFIreturns, and a loop that sleeps again spins. Check for stray flags such as the wake-up flag inPWR->CSRand a leftover EXTI pending bit.Debugging stops working. In Sleep, Stop and Standby, the debug port loses its clock by default, so the debugger disconnects. A later post covers
DBGMCUbits that keep it alive.Peripherals still draw current. Clock gating and pin states matter as much as the mode. A floating or driven GPIO pin leaks, and a pull-up fighting a pin held low wastes microamps.
Missing the wake-up. A
WFIentered just after the event arrives is fine, because the pending interrupt wakes it. A flag checked before and acted on after theWFI, with a gap, is not, and the next post shows the guard.


