cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_RTCex_SetWakeUpTimer_IT() Not working properly

shawn2
Associate II
Posted on November 17, 2015 at 21:13

Greetings, 

So I decided to play with the RTCex library, specifically the much abbreviated new timer_IT function.  My system is designed to shutdown after every code iteration and be awakened via the alarm(wakeup timer).

The issue is, the timer only works up to 30seconds.  I can input any counter up to that point and the system wakes near the specified time.  Not sure why, other than maybe I'm catching a edge at that point somehow.  Thoughts?   I've tried changing the RTC config parameters as well (WAKEUP, PUSHPULL, etc), to no avail.

Here is my code so far:

&sharpdefine ALARM_TIMER ox1E046  //60s (considering 16MHz clock, using LSI) 

__HAL_RCC_PWR_CLK_ENABLE();

 HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);

__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);

  

  /*♯♯ Setting the Wake up time ♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯*/

HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, ALARM_TIMER,

RTC_WAKEUPCLOCK_RTCCLK_DIV16);

  

  /* Request to enter STANDBY mode  */

HAL_Delay(3000);

HAL_PWR_EnterSTANDBYMode(); //***ENTER STANDBY***

//Configuration is thus (as recommended by another RTCex thread and CubeMX):

void MX_RTC_Init(void)

{

    /**Initialize RTC

    */

  hrtc.Instance = RTC;

  hrtc.Init.HourFormat = RTC_HOURFORMAT_24;

  hrtc.Init.AsynchPrediv = 127;

  hrtc.Init.SynchPrediv = 255;

  hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;

  hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;

  hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;

  HAL_RTC_Init(&hrtc);

}

void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)

{

  if(hrtc->Instance==RTC)

  {

  /* USER CODE BEGIN RTC_MspInit 0 */

  /* USER CODE END RTC_MspInit 0 */

    /* Peripheral clock enable */

    __HAL_RCC_RTC_ENABLE();

/* Peripheral interrupt init*/

    HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 0, 0);

    HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);

  /* USER CODE BEGIN RTC_MspInit 1 */

  /* USER CODE END RTC_MspInit 1 */

  }

}

#rtc #wakeup #timer #stm32
2 REPLIES 2
mbruder
Associate II
Posted on February 24, 2016 at 18:48

Try changing the clock source for the WUT:

HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, ALARM_TIMER,

RTC_WAKEUPCLOCK_RTCCLK_DIV16);

For:

HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, ALARM_TIMER,

RTC_WAKEUPCLOCK_CK_SPRE_16BITS);

Let me know!

Walid FTITI_O
Senior II
Posted on February 29, 2016 at 19:16

Hi eclipsePhage,

The AsynchPrediv and synchPrediv that you are using are dedicated to LSE. In case of LSI, Try to use (AsynchPrediv = 124, synchPrediv = 295). [with STM32F2xx and STM32F4xx]

Onother detail, you should clear all the flags just before entering the standby mode. (after

HAL_RTCex_SetWakeUpTimer_IT() ) 

-Hannibal-