cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3: RTC wakeup interrupt not occur!

bhcuong2008
Associate II
Posted on May 25, 2016 at 18:20

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);

}

===

#stm32f3discovery
1 REPLY 1
bhcuong2008
Associate II
Posted on May 25, 2016 at 19:49

Solved it. I power off the board then power on again. This way, it forces RTC running.