Skip to main content
ledi001
Associate III
September 30, 2019
Question

Problems with RTC - wakeup from STOP-Mode

  • September 30, 2019
  • 2 replies
  • 1346 views

Hi,

i am using a STM32L010K8 MCU and i want to wake up from stop mode when a RTC-Wakeup interrupt occours. Here in this example i set the RTC wakeup interrupt for 30 seconds. Without entering the sleep mode the RTC IRQ works fine. But if the MCU enters the sleep mode, it seems that the MCU doesn't wake up anymore. Here are the regarding code instructions:

Set a flag in the Wake-up timer IRQ in file stm32l0xx_hal_rtc_ex.c

void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc)
{
 /* Get the pending status of the WAKEUPTIMER Interrupt */
 if (__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) != 0U)
 {
 wakeupFlag = 1; // set the Flag if a wakeup event occours
 }
...
...
...

In main() routine, if wakeupFlag != 0 read some sensor values, otherwise enter STOP mode and sleep as long a new RTC-wakeup IRQ occours.

while (1)
{
 if(wakeupFlag == 0)
 {
 HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
 __WFI();
 }
 
 if(wakeupFlag == 1)
 {
 if(sensorFlag == 1)
 {
 sensorFlag = 2;
 // read Sensor 1
 }
 else if(sensorFlag == 2)
 {
 sensorFlag = 3;
 // read Sensor 2
 }
 else if(sensorFlag == 3)
 {
 sensorFlag = 1;
 // read Sensor 3
 }
 }
}

This topic has been closed for replies.

2 replies

ledi001
ledi001Author
Associate III
October 1, 2019

​Problem solved!

ADing.1
Associate II
June 28, 2023

I have the same issue. Thanks a lot for describing your solution...