2023-03-22 09:43 AM
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
Solved! Go to Solution.
2023-03-30 10:44 PM
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
2023-03-23 01:00 AM
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.
2023-03-23 02:32 AM
Hi,
thank you for the super fast response.
Maybe I need to clarify some things:
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
2023-03-30 10:44 PM
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