2022-04-09 11:06 PM
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
Solved! Go to Solution.
2022-04-10 04:04 AM
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
2022-04-10 04:04 AM
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
2022-04-12 12:26 AM
Thank you KnarfB
2022-04-15 12:03 AM
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?
2022-04-16 12:13 PM
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.
2022-04-17 07:17 PM
The example clear these 2 flags:
/* Clear Standby flag*/
LL_PWR_ClearFlag_SB();
/* Reset RTC Internal Wake up flag */
LL_RTC_ClearFlag_WUT(RTC);
This one was missing:
/* Clear wakeup flag */
LL_PWR_ClearFlag_WU();