AnsweredAssumed Answered

STM32F3: RTC wakeup interrupt not occur!

Question asked by bui.cuong on May 25, 2016
Latest reply on May 25, 2016 by bui.cuong
Hi,

I'm setting RTC for wakeup interrupt using HAL as below but the interrupt not happen. Please give me your advice.

Thanks.

P/s:
- These codes are based on CubeMX.
- Other settings required for system running is done by CubeMX generated-code. I don't include it here.

===
int main(void)
{
  // setup RTC
  RTC_HandleTypeDef hrtc;

  hrtc.Instance = RTC;
  hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
  hrtc.Init.AsynchPrediv = 100;
  hrtc.Init.SynchPrediv = 400;
  hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
  hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
  hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;

  HAL_RTC_Init(&hrtc)


  HAL_RTCEx_SetWakeUpTimer_IT(hrtc, 3, RTC_WAKEUPCLOCK_CK_SPRE_16BITS);

  while(1) {
  }

}



void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
{
  // called by HAL_RTC_Init

  if(hrtc->Instance==RTC)
  {
    __HAL_RCC_RTC_ENABLE();
    HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);
  }

}

void RTC_WKUP_IRQHandler(void)
{
    printf("Wakeup Timer Interrupt\n");
    HAL_RTCEx_WakeUpTimerIRQHandler(&hrtc);
}

===

Outcomes