machine.RTC.datetime() seconds change out of sync with subseconds rollover #10122
-
I am reporting a bug. While running MicroPython 1.19.1 on Teensy 4.1 I have noticed that the
On documentation, it says "The meaning of the subseconds field is hardware dependent.", but I think this is very strongly undesired and unexpected output. If the subseconds-field is used directly as UTC microseconds, this causes there to be once per second a 33ms time window when the RTC returns time that is 1s off from the true time. Minimal code for reproducing the output:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Thank you for the observation. The problem is by design and cannot be fixed. The MIMXRT10xx RTC module does not have a subsecond counter. It is emulated in the software, by taking the ticks_us64() counter with an offset. The offset is remembered when the time is set with datetime(). So there are two inherent problems:
The only alternative to the actual approach is not providing a subsecond reading at all. That's reliable. |
Beta Was this translation helpful? Give feedback.
Thank you for the observation. The problem is by design and cannot be fixed. The MIMXRT10xx RTC module does not have a subsecond counter. It is emulated in the software, by taking the ticks_us64() counter with an offset. The offset is remembered when the time is set with datetime(). So there are two inherent problems:
The only alternative to the actual approach is not providing a subsecond rea…