How to fire RTC alarm every 1s?
Today, for the first time I tried to set up RTC alarm using STM32U5G9 MCU. I need RTC alarm (IRQ) to fire on every second change, that is, when subsecond counter is zero - it is configured to count 32kHz clock pulses from 32k to 0 using 15-bit subsecond register which should zero exactly every one full second.
Probably what needs to be done is this: 1. alarm needs to enabled, 2. subsecond SS mask needs to be set to 14:0 (all 15 bits are compared), 3. RTC IRQ needs to be enabled, 4. within ISR alarm has to be reset (RTC_SCR_CALRAF) or auto-clear (RTC_CR_ALRAFCLR) flag needs to be set in advance (sAlarm.FlagAutoClr = ALARM_FLAG_AUTOCLR_ENABLE).
The above does not work, RTC IRQ does not fire even once. RTC date/time works OK so it is not a clock issue.
Please advice. What am I missing?
I am familiar with ST Wiki publication on this subject here but it did not work, I was unable to fire RTC IRQ even once. In any case, I think the described approach is very unreliable - what if RTC IRS gets interrupted by another high-priority IRS executing for more than a second before new alarm is set?




