STM32L051 has excellent performance in terms of low power consumption. According to the official DATA manual of ST, the current consumption can reach 0.4uA in stop without RTC mode and 0.8uA in stop with RTC mode.
The code consists of two parts:
- Stop with RTC,wake up with RTC.
- Stop without RTC,wake up with external interrupts, such as keystrokes and serial ports to receive external data.
- Set the external setting before entering STOP mode, and the GPIO is set to the analog input state.
- Set the wake-up time of the RTC in seconds.
- Call the library function into STOP mode.
- Restore the clock after quitting STOP mode.Note in particular that the system clock becomes MSI when you enter STOP mode.
- Restore peripheral states, such as GPIO, serial port initialization.
- Call the function directly where you need to enter STOP mode.
- Before entering the STOP mode to set the external device, the GPIO should be set to the simulated input state, cancel the serial port configuration to restore the default.
- Set the wake-up source interrupt, where keystrokes and serial rX-associated interrupts are configured.
- Call the library function into STOP mode.
- Restore the clock after quitting STOP mode.Note in particular that the system clock becomes MSI when you enter STOP mode.
- Restore peripheral states, such as GPIO, serial port initialization.
- Call the function directly where you need to enter STOP mode.