cancel
Showing results for 
Search instead for 
Did you mean: 

WAKEUP with RTC_WAKEUPCLOCK_CK_SPRE_16BITS not Working

FBald.1
Associate III

Hi everyone,

I have a problem with the STM32F401RE wakeup timer setup, to exit standby.

This is my code.

* Disable Wake-up timer */

 HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);

 /*## Clear all related wakeup flags ###################################*/

 /* Clear PWR wake up Flag */

 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

 /* Clear RTC Wake Up timer Flag */

 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&RTCHandle, RTC_FLAG_WUTF);

 /*## Setting the Wake up time ######################################*/

      

  HAL_RTCEx_SetWakeUpTimer(&RTCHandle, 60, RTC_WAKEUPCLOCK_CK_SPRE_16BITS);

 /*## Enter Standby Mode##########################################*/

 /* Request to enter STANDBY mode */

 HAL_PWR_EnterSTANDBYMode();

If I use the

HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0x2805,RTC_WAKEUPCLOCK_RTCCLK_DIV16);

it works well

But if I want longer times and use  HAL_RTCEx_SetWakeUpTimer(&RTCHandle, 60, RTC_WAKEUPCLOCK_CK_SPRE_16BITS);

it does not come out of the standby condition. aftet 60 seconds

What's wrong.

A little help, Please.

Fausto

1 REPLY 1
SMush.2
Associate

You need to use HAL_RTCEx_SetWakeUpTimer_IT instead of HAL_RTCEx_SetWakeUpTimer. HAL_RTCEx_SetWakeUpTimer doesn't set up registers for generating interrupts or events.

If you wish to be woken up by an RTC wakeup event instead of an RTC wakeup interrupt, you'll need to write your own HAL-like library. This is not difficult. Just copy HAL_RTCEx_SetWakeUpTimer_IT and replace "__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT" with "__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT".

Incidentally, you call __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG directly, but this has no effect. To modify RTC_ISR register, you have to follow the correct procedure described in the datasheet. At any rate, this task is done inside HAL_RTCEx_SetWakeUpTimer_IT, so you don't have to worry about it.