cancel
Showing results for 
Search instead for 
Did you mean: 

Why setting up RTC WKUP interrupt will generate HAL_RTCEx_SetWakeUpTimer_IT in init?

Tuoman
Senior II

I want to enable RTC WKUP interrupt, so that I can use it later to wake the device up from sleep modes.

Nevertheless, CubeMX will also add HAL_RTCEx_SetWakeUpTimer_IT in init. I don't want to launch the timer in init! I only want to set it up for later use (setup interrupt handlers, NVIC enable).

  1. Is this call 100% necessary? Why CubeMX generates it in init?
  2. What does it mean if WakeUpCounter parameter to this call is 0?
2 REPLIES 2

Hi @Tuoman​ 

> Is this call 100% necessary? Why CubeMX generates it in init?

Yes STM32CubeMX calls this function when we activate the WakeUp, then go to the NVIC Settings table and Enable the RTC wake-up interrupt Through EXTI line 19.

0693W000005ARhCQAW.pngWhen we generate code: we get this function

HAL_RTCEx_SetWakeUpTimer_IT

0693W000005ARi0QAG.pngWhen we uncheck the RTC wake-up interrupt Through EXTI line 19

0693W000005ARj8QAG.pngThen we go to the generated code: we get this function HAL_RTCEx_SetWakeUpTimer

0693W000005ARkfQAG.png> What does it mean if WakeUpCounter parameter to this call is 0?

0 is the default value, you can change it :

0693W000005ARlsQAG.pngBest regards,

Nesrine

Hello, Nesrine. Unfortunately this did not answer my question at all. You answered how to setup WakeUp in CubeMX (I already know) and that I can change value from 0 (I already know)

My questions still remain;

  1. Why is the HAL_RTCEx_SetWakeUpTimer_IT call necessary? I don't want to start the timer in init, I just want to set it up for later use. Why CubeMX automatically generates it in init? Is this CubeMX bug?
  2. What does it mean if WakeUpCounter parameter to this call is 0? "0 is the default value" What does it do? Launch timer interrupt immediately? Nothing? Will it break something?