RTC issues on PYBD (STM32)
We've encountered a number of issues using the RTC on PYBD across a number of devices. These include
- RTC stopping entirely (subsequent calls to the RTC return exactly the same value)
- RTC blocking for ~1 sec when getting or setting the time
- RTC returning a plausible but incorrect value (I think a bit has become 'stuck')
These faults are often intermittent making debugging quite difficult.
As such, for our application code we are now using a 'soft' RTC based off CPU ticks, and synchronising from the network on a regular basis.
machine.rtc feature request: rtc.ticks_ms()
Support rtc.ticks_ms(). This would return a value compatible with the port's utime.ticks_diff() and utime.ticks_add().
Use case: uasyncio uses utime.ticks_ms() as its timebase. In a light sleep state this clock stops. However it is possible to replace this clock with one based on the RTC. This enables a class of application which waits, with reduced power consumption, on an event such as a button press or a time period. uasyncio continues to run, but spends most of the time in light sleep. I have tested this with custom code on Pyboards. This feature would enable portable code to be written.
FYI:
This works by running a coro which puts the target into light sleep for a period. When it wakes, it allows all pending coros to run once before sleeping again. Coros can alter the period or disable sleeping, enabling dynamic control of power consumption/performance. This works on Pyboards under my fork of uasyncio. Porting it to new uasyncio is waiting pending a stable version but I can't see any obvious difficulty.