Skip to main content
migmel
Associate III
April 10, 2022
Solved

How to enter STM32L071CB in sleep mode and how to wake it up using LL library?

  • April 10, 2022
  • 5 replies
  • 2304 views

Hello, I'm working in a project to receive GPS NMEA sentences and send data thru 4G TCP connection every 10 minutes.

During 1 cycle all the process to receive and send data lasts about 1 minute, the rest 9 minutes the 4G/GPS module is shut down and the MCU needs to be set to sleep mode to minimize power consumption.

Until now everything but setting MCU in sleep mode has been done right . However I am not clear in how to send MCU to sleep, but more importantly, after in sleep mode, how to wake it up to start the next 10 minutes cycle?

Also, when in sleep mode I would like to switch the internal clock which makes MCU run at 32MHz to LSE clock( 32768 Hz)

I will appreciate any help/suggestion about this.

thank you in advance

This topic has been closed for replies.
Best answer by KnarfB

You save more energy by using standby mode. Nearly thw whole MCU is off, only the RTC (real time clock) is running on LSE and issuing a periodic alarm which wakes up the MCU. You may start with sample code like https://github.com/STMicroelectronics/STM32CubeL0/tree/master/Projects/NUCLEO-L073RZ/Examples_LL/RTC/RTC_ExitStandbyWithWakeUpTimer, reading https://forum.digikey.com/t/low-power-modes-on-the-stm32l0-series/13306 or watching videos.

hth

KnarfB

5 replies

KnarfB
KnarfBBest answer
Super User
April 10, 2022

You save more energy by using standby mode. Nearly thw whole MCU is off, only the RTC (real time clock) is running on LSE and issuing a periodic alarm which wakes up the MCU. You may start with sample code like https://github.com/STMicroelectronics/STM32CubeL0/tree/master/Projects/NUCLEO-L073RZ/Examples_LL/RTC/RTC_ExitStandbyWithWakeUpTimer, reading https://forum.digikey.com/t/low-power-modes-on-the-stm32l0-series/13306 or watching videos.

hth

KnarfB

migmel
migmelAuthor
Associate III
April 15, 2022

I follow the example you suggested in the link and it works fine. There was missing a flag to clear so the next times the MCU woke up immediately after entering SB...

Now a new challenge appears: Every cycle before entering StandBy mode I send a frame with a sequence number. However after waking up from SB the sequence is lost and the frame is numbered as the first one. Can you give any suggestion in how to preserve this data so it can continue the sequence number?

Piranha
Principal III
April 16, 2022

Which flag was it? WUF and/or SBF in PWR_CSR register?

You have 20 bytes of backup registers in RTC. If that is not enough, use Stop mode, which preserves SRAM content.

migmel
migmelAuthor
Associate III
April 12, 2022

Thank you KnarfB