← index #12957Issue #1523
Related · high · value 3.260
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

interaction between pyb.standby() and pyb.rtc()

closedby jimtal001opened 2015-10-20updated 2015-11-05
ports

While preparing to calibrate the RTC using rtc.calibration (), I found that there is a bug related to pyb.standby(). Using pyb.standby() a small amount of time is lost to the RTC with each wakeup (around 0.2 sec). To reproduce the issue use the following code (time_cal.py) to set, syncronize and output the time to PC for a one hour period. At the end of the one hour period I found approximately a 19,000 ppm (tick) delta between PC and pyboard. The mode pyb.stop() does NOT have this issue and adding a battery backup VBAT does not fix the issue for pyb.standby().

import pyb, stm
import micropython

rtc = pyb.RTC()
sleepTime = 10000 # in ms

def main():
   if (stm.mem32[stm.RTC + stm.RTC_BKP1R] == 0): # first boot, Code to run on 1st boot only
      rtc.datetime((2015,10,19,1,16,45,0,0))

   print(rtc.datetime())
   rtc.wakeup(sleepTime)
   stm.mem32[stm.RTC + stm.RTC_BKP1R] = 1 # indicate that we are going into standby mode
   pyb.standby()

main()

This is my boot.py

import pyb
import micropython
pyb.usb_mode(None)
uart = pyb.UART(4,115200)
pyb.repl_uart(uart)
pyb.main('time_cal.py')

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