← index #12957Issue #5422
Related · high · value 2.632
QUERY · ISSUE

RTC issues on PYBD (STM32)

openby victorallumeopened 2023-11-13updated 2024-04-10
bug

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.

CANDIDATE · ISSUE

machine.rtc feature request: rtc.ticks_ms()

openby peterhinchopened 2019-12-16updated 2019-12-17

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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied