RTC should contain an assertion checking if the prescaler values are configured or not. Or check if configured and if not, call the function to compute the values.
In case only a soft reset is performed, the RTC remains initialized, the above mentioned code is not executed and prescaler values are not calculated. Therefore they remain set to -1. Then when setting and RTC alarm with subseconds enabled, the following issue occurs:
This leads to reserved bits in the register being written to 1 and generally incorrect behaviour. This is not easy to debug and just a note in the readme that the function setPrediv() must be called before begin() can easly be missed.
The examples also don't call this function, which makes the issue even more hidden. Maybe some boards ensure that invalid values are not written to registers and this issue is not observed on them.
RTC should contain an assertion checking if the prescaler values are configured or not. Or check if configured and if not, call the function to compute the values.
This portion of code https://github.com/stm32duino/STM32RTC/blob/95b7514045237495364b62d4faf23d484017640a/src/rtc.c#L382-L398 is executed only when the device was previously unpowered -> RTC is not initialized. For the case when RTC is not initialized the function https://github.com/stm32duino/STM32RTC/blob/95b7514045237495364b62d4faf23d484017640a/src/rtc.c#L391 is called and prescaler values are computed.
In case only a soft reset is performed, the RTC remains initialized, the above mentioned code is not executed and prescaler values are not calculated. Therefore they remain set to -1. Then when setting and RTC alarm with subseconds enabled, the following issue occurs:
This leads to reserved bits in the register being written to 1 and generally incorrect behaviour. This is not easy to debug and just a note in the readme that the function setPrediv() must be called before begin() can easly be missed.
The examples also don't call this function, which makes the issue even more hidden. Maybe some boards ensure that invalid values are not written to registers and this issue is not observed on them.