Subsection 16.2.1 The Four Modes, and Their Entry Values
The four modes are summarized in Table 16.1.11; Reference Manual §4.3 and its Table 19 carry the full accounting, and the details worth having when you come back to this are the following. Sleep stops the CPU clock only. Stop also stops the high-speed oscillators, the HSI48 and the HSE (the high-speed external oscillator); SRAM and register contents are retained, the LSI and the LSE (the low-speed internal and external oscillators) can keep running, and exiting re-enables the HSI48 with the system clock divider left at whatever it was set to before entry. Standby powers off the core’s supply domain: SRAM and register contents are lost and
PWR_CR1 is reset to its default, while PWR_CR3, PWR_CR4 and the backup registers are retained and the IWDG and LSI can keep running. Shutdown disables all oscillators and the supply monitor; contents are lost, and exiting behaves like a reset.
Entry is controlled by SLEEPDEEP (in the Cortex-M0+ system control register,
SCB->SCR) and LPMS[2:0] (in PWR_CR1, Figure 16.1.16), then executing __WFI() or __WFE() (Reference Manual §4.3.2, Table 20):
| Mode | SLEEPDEEP | LPMS[2:0] |
|---|---|---|
| Sleep | 0 | any |
| Stop | 1 | 000 (the reset value) |
| Standby | 1 | 011 |
| Shutdown | 1 | 1XX |
Waking from Sleep or Stop resumes execution after the
__WFI(); the pending flag of the interrupt that caused the wake must be cleared as usual. Waking from Standby or Shutdown restarts the program from the beginning, as after a reset.
