cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_RTCEx_SetWakeUpTimer_IT issue (STM32L475RC)

adrian
Associate III

Hi,

I'm really struggling with this, I cannot find any reason for the problem I'm seeing, I've looked at the example code in the firmware packages and I have identical code to the examples.

I'm using HAL to configure the project, the RTC is clocked from LSE which is up and running.

I call:

    MX_RTC_Init();

And I can see that the registers change as expected.

I then call:

 HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);

HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x5000, RTC_WAKEUPCLOCK_RTCCLK_DIV16);

Which should result the RTC_WKUP_IRQHandler being called, but it never is.

If I look after 10 seconds at the RTC status registers I can see that WUTF is set.

I've tried adding:

__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);

In various places as it seems that may be required after reading around, but it makes no difference, I cannot get the interrupt to fire, other interrupts from other peripherals are working fine.

My HAL_RTC_MspInit has the following code:

  __HAL_RCC_RTC_ENABLE();

 HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 0, 0);

 HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);

Any suggestions?

14 REPLIES 14
Imen.D
ST Employee

Hello @adrian​ ,

There is a problem in the "stm32l4xx_hal_rtc_ex.c" file within the new version of STM32CubeL4 V1.13.0: The macro '__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();' is missing in the HAL_RTCEx_SetWakeUpTimer_IT function (for other devices than STM32L412xx/STM32L422xx).

To fix this issue: the macro __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT()" in the HAL_RTCEx_SetWakeUpTimer_IT function should be added instead of "__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT" ( in line 912)

Hope this helps you.

Please keep us informed about your update.

Kind Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

This did indeed fix the issue, I now get the Wakeup interrupt!

Many thanks

 We have already passed this issue along to our development team for fix in the coming release.

Kind Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

I asked above about exti, and adrian answered

> The EXTI is set correctly.

which I assume he said after reading out and checking the relevant EXTI registers bits.

Or not?

JW

Apparently it wasn't, I must have looked at the wrong register as it looked like it was set, but clearly wasn't.

The fix correctly fixes it, sounds like you correctly identified it but I just didn't see it.