it is a few years I have implemented RTC for BigClown scheduler so I may be a little wrong but here is what I remember
The scheduler and tick is running from RTC, the RTC has 32768 Hz crystal. You can easily use 15 bit counter (2^15) in the RTC to get correct number of seconds. But we needed more precise time slices for scheduler so we have decided for compromise that the tick and scheduler will be incremented in 10 ms intervals. That means that you have to count 32.768 which equals to 10ms. But what with that 0.768 fraction when MCU registers are integers? There is a 16x divider and WUTR (wake-up timer register) register is 20, that means that 10ms is in real
You can cheat a little bit and change the WUTR to 19 for a few cycles to compensate, you can get close to 10ms but you cannot get exactly to 10ms. So we have accepted this inaccuracy.
Good news - today we’ve implemented RTC date and time basic functions.
(you don’t have to call bc_rtc_init function, it is empty right now and initialization of RTC is always done in by_system)
It is far from perfect. In the future we would like to add some software timer callbacks for call once a:
But now you have to create your own code for example in a task, that will check the RTC time.
We need to do some further testing for precision. There is still some innacuracy around fraction second a day, but it is much more usable than with a bc_tick.