cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to use RTC wakeup interrupt without Low Power?

TZier.1
Associate II

Hi,

I'm using Nucleo-l476RG and try to get an Interrupt with RTC accuarcy every second.

My plan is to use the RTC WakeUp in Internal WakeUp mode with "RTC wake-up interrupt through EXTI line 20"

However the problem is that the interrupt is fireing only once and then the WUTF in the RTC_ISR cannot be reset.

I'm using the cubemx generated code and implement the interrupt with the following code:

void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
{
	HAL_Delay(1);
}

and activate the time with the following:

HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 10, RTC_WAKEUPCLOCK_CK_SPRE_16BITS);

What am I missing?

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
TZier.1
Associate II

Hi,

I found the solution:

We were using the function HAL_PWR_DisableBkUpAccess(void) after writting to backup registers. This blocked the access to the WUTF.

I hope this helps someone else.

Regards

View solution in original post

3 REPLIES 3
Sarra.S
ST Employee

Hello @TZier.1​ and welcome to ST Community,

Thank you for posting your issue!

First, I am not sure why you are using the HAL_Delay function inside the RTC wake-up timer callback function... it can block other interrupts and delay the processing of other events in your system

But most importantly, It seems that the issue is that you are not clearing the RTC wake-up flag before exiting ISR. Since the RTC wake-up flag is not cleared, the ISR will only be triggered once and then it will not be triggered again.

So, Make sure that you clear it at the beginning of the callback function :

 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);

Hope that helps!

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.

TZier.1
Associate II

Hi,

thank you for the super fast response.

Maybe I need to clarify some things:

  1. The HAL_Delay is just a placeholder for debuging. The problem is the same when using LED_Toggle for example.
  2. I didn't post the cubemx generated ISR which is as follows
void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc)
{
  /* Clear the EXTI's line Flag for RTC WakeUpTimer */
  __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG();
 
 
#if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  if ((hrtc->Instance->MISR & RTC_MISR_WUTMF) != 0u)
  {
    /* Immediately clear flags */
    hrtc->Instance->SCR = RTC_SCR_CWUTF;
#else
  /* Get the pending status of the WAKEUPTIMER Interrupt */
  if (__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) != 0U)
  {
    /* Clear the WAKEUPTIMER interrupt pending bit */
    __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
#endif
 
    /* WAKEUPTIMER callback */
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
    /* Call WakeUpTimerEvent registered Callback */
    hrtc->WakeUpTimerEventCallback(hrtc);
#else
    HAL_RTCEx_WakeUpTimerEventCallback(hrtc);
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
  }
 
  /* Change RTC state */
  hrtc->State = HAL_RTC_STATE_READY;
}

This means I am clearing the WUTF, but I can see from the debugger that it is not cleared for some unknown reason.

Is there maybe an example showing the RCT wake up without low power? I only know the "RTC_LSI RTC prescaler adjustment with LSI Measurements example"

Regards

TZier.1
Associate II

Hi,

I found the solution:

We were using the function HAL_PWR_DisableBkUpAccess(void) after writting to backup registers. This blocked the access to the WUTF.

I hope this helps someone else.

Regards