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.
2019-06-04 09:53 AM
Clear the RTC ISR first. Maybe add a barrier (DSB), then clear the pending IRQ from EXTI.
Otherwise, the EXTI-flag may set again, before you get the RTC IRQ cleared.
That _might_ be the problem.
2019-06-05 01:49 AM
2019-06-06 11:11 AM
Memory barrier (dmb) may not be enough, you may need barrier over the AMBA-bus - system barrier (dsb).
I'd check whether the interrupt pending bit is really reset before return, or maybe after return (breakpoint after sleep).
And I'd check that also just before second attempt to sleep.
2019-06-06 11:15 PM
2020-03-15 01:18 AM
I have same problem but I use STM32F205RCT6. Wake up only happen once, the WUTF bit in RTC_ISR register can not be cleared. WPuch, did you sort the problem?
2020-03-17 12:22 AM
For now all works. don't remember exactly what was wrong but now works. contact me directly (wojtek@puchar.net) if you need more info.
2021-04-29 08:21 AM
I have same RTC Alarm Only Once bug in my STM32L496RG project as of 4/29/2021 using HAL 1.16.0 from CubeMX 6.1.1.
Root cause: ALMAF not cleared in ISR.
My solution was to add the following to the HAL callback routine in my code;
/* Clear the RTC Alarm-A Flag */
HAL_PWR_EnableBkUpAccess();
__HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRAF);
HAL_PWR_DisableBkUpAccess();
2021-05-03 09:01 PM
I was having a similar problem with the RTC wakeup timer interrupt only firing once even though I was clearing the RTC_ISR_WUTF flag. The solution: I had to disable write protection before I could clear the RTC_ISR_WUTF flag.
// Disable RTC write protection
RTC->WPR = 0xCA;
RTC->WPR = 0x53;
// Clear WUT pending flags
RTC->ISR &= ~RTC_ISR_WUTF;
// Enable write protection
RTC->WPR = 0xFFU;
2021-05-03 09:54 PM
Hi, @RLind.3 ,
In which STM32?
JW