2023-08-09 02:43 AM
We are developing a device that periodically boots in Sleep mode using the STM32G04.
Set the WakeUpTime with HAL_RTCEx_SetWakeUpTimer_IT and enter Sleep with HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);.
If you make a program to Sleep for 10 minutes, the RTC time is the same before and after startup and the RTC is not counting during Sleep.
The time in Sleep is set to 10 minutes, but even if I do HAL_RTC_GetTime, the value is the same before Sleep and after Sleep.
Is it possible to make it so that the RTC is updated during Sleep?
2023-08-09 03:01 AM
Hello J_m,
First of all I can see that you are entering stop mode rather than sleep mode with HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
In this case I would like to know how you clocked your RTC please?
Regards,
Stassen
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-08-09 05:20 PM
Hello Stassen
I would like to use the STOP mode.
I want to see how much time has passed before entering STOP mode and after wake up.
2023-08-10 01:46 AM
Hello J_m,
In this case i suggest you:
- clock your RTC with the LSE
- Before going into stop mode, read the RTC counter value
- Enter STOP mode
- Upon wakeup you read the RTC counter value
Note that in stop mode all clocks are switched off except the LSE/LSI.
Hope this helps.
Regards,
Stassen
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-08-10 02:23 AM
Hello Stassen
Thanks.
Is the following code sufficient to set up the RTC to run on LSE?
2023-08-10 05:16 AM
J_m,
That should do it, just check that in the HAL_RTC_MspInit the clock selection is also LSE.
Regards,
Stassen
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-08-14 12:24 AM
Thank you very much.
I can confirm that the RTC is updated.