2019-06-04 01:38 AM
I initialize RTC timer by first clearing RTC_CR register,then waiting until WUTWF bit is on, then setting RTC WUTR register to 100, and RTC_CR to 0x4420 (wakeup timer enable, wakeup interrupt enable, bypass shadow). Bypass shadow register is set for other things.
This setting should generate interrupt 2048/100=about 20 times per second
NVIC is enabled for RTC wakeup interrupt, EXTI is properly set to rising edge for line 20.
The interrupt handler clears bit in EXTI_PR1 by writing 1 and clear bit 10 in RTC_ISR.
NET EFFECT: one interrupt is generated. that's all.
What i am doing wrong.
2021-05-04 12:31 PM
STM32L010RB (Nucleo-L010RB)
2025-01-08 02:40 AM
Had the exact same problem and your solution fixed it.
In my code i wrote something in the RTC backup register:
HAL_PWR_EnableBkUpAccess();
HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, 0);
HAL_PWR_DisableBkUpAccess();
If i uncommet HAL_PWR_DisableBkUpAccess(); it works like a charm also without your fix.
My solution was to add your clear flag code in the AlarmA Event Callback:
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc) {
// ***
// custom code
// ***
// Clear the RTC Alarm-A Flag
HAL_PWR_EnableBkUpAccess();
__HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRAF);
HAL_PWR_DisableBkUpAccess();
}
Now it triggers an Alarm as expected, thank you!