Closed FRASTM closed 1 year ago
with this PR and running the sketch mixRTCAlarm:
18:23:23.681 -> Start at 16:22:06.199
18:23:23.776 -> Set Alarm A in 12s (at 16:22:18)
18:23:23.776 -> Set Alarm B (in 400 ms) at 597 ms
18:23:24.099 -> Alarm B Match at 597 ms
18:23:35.495 -> Alarm A Match at 16:22:18
Now squashed in https://github.com/stm32duino/STM32RTC/pull/93
STM32RTC APi has subsecond parameter which is a value in milliseconds
Becasue of the BINARY MIX mode, the parameter subsecond could be confusing as the subsecond register of the RTC is:
For example, in MIX mode, when RTC is clocked by the LSE (32768Hz) the tick is downcounting at 256Hz (1 tick is ~ 3.9ms ) The RTC subsecond register is converted in ms by
(0xFFFFFFFF - SubSecReg) * 1000/256
And N miliseconds is converted in ticks (count unit) by0xFFFFFFFF - (SubSecReg * 256) /1000
With this PR, the STM32RTC API is always giving the subsecond parameter in a nb of milliseconds. Especially with functions:
getSubSeconds() and getTime()
getAlarmSubSeconds()
setAlarmSubSeconds() and setAlarmTime()
setSubSeconds() and setTime() (but Subsecond value is ignored there RO register)