stm32: time.time() always returning 0
We're running a Pyboard-D SF6W and the RTC seems to hang from time to time.
MicroPython v1.10-445-ga9b1d3ca3-dirty on 2019-06-18; PYBD_SF6W with STM32F767IIK
Type "help()" for more information.
>>> import time
>>> time.time()
0
Soft Reset (doesn't work)
Software accessible resets do not fix the issue... the following attempts to reboot are done without removing power.
machine.reset
>>> import machine
>>> machine.reset()
...
MicroPython v1.10-445-ga9b1d3ca3-dirty on 2019-06-18; PYBD_SF6W with STM32F767IIK
Type "help()" for more information.
>>> import time
>>> time.time()
0
pyb.hard_reset()
>>> import pyb
>>> pyb.hard_reset()
...
MicroPython v1.10-445-ga9b1d3ca3-dirty on 2019-06-18; PYBD_SF6W with STM32F767IIK
Type "help()" for more information.
>>> import time
>>> time.time()
0
Physical Reset (ie: completely remove power)
However, if pyboard is completely powered off (tested for ~3sec).
The problem is resolved.
MicroPython v1.10-445-ga9b1d3ca3-dirty on 2019-06-18; PYBD_SF6W with STM32F767IIK
Type "help()" for more information.
>>> import time
>>> time.time()
473385659
stmhal: rtc.datetime() throws an exception if called without arguments
The documentation for pyb.RTC on the pyboard says that without any arguments the method will return the current time as an 8-tuple; with one argument (an 8-tuple) the RTC will be set. The comments in the code say the same:
/// With no arguments, this method returns an 8-tuple with the current
/// date and time. With 1 argument (being an 8-tuple) it sets the date
/// and time.
However, the code disagrees:
mp_obj_t pyb_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args == 1) {
// get date and time
// note: need to call get time then get date to correctly access the registers
and:
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_rtc_datetime_obj, 1, 2, pyb_rtc_datetime);
The behavior is consistent with the code (naturally):
Micro Python v1.4.3-159-g3ce212e on 2015-06-14; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> import pyb
>>> rtc = pyb.RTC
>>> dir(rtc)
['info', 'datetime', 'wakeup', 'calibration']
>>> rtc.datetime()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function missing 1 required positional arguments
>>> rtc.datetime('foo')
(2014, 1, 1, 3, 0, 37, 49, 203)
>>> rtc.datetime((2015, 6, 14, 7, 0, 0, 0, 0))
(2014, 1, 1, 3, 0, 39, 11, 86)
>>> rtc.datetime('foo',(2015, 6, 14, 7, 0, 0, 0, 0))
>>> rtc.datetime('foo')
(2015, 6, 14, 7, 0, 0, 5, 101)
>>> rtc.datetime()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function missing 1 required positional arguments
Am I reading this wrong? I made a simple change (three lines) to rtc.c and produced the behavior as documented, but I don't understand why it would have been different in the first place...