I have a project which uses the Pyboard's low power modes and an RTC backup battery. The situation I'm about to describe convinced me there was an intermittent fault with my hardware so I built a new set. I've now seen it on the new set too. The hardware of both sets is properly constructed with a PCB. I'm unsure what triggers it: it doesn't occur in unattended operation but only when I'm making changes to the system. The symptoms are as follows.
The REPL works fine but the RTC is at the initial value set by the firmware. If I try to set it with rtc.datetime((8-tuple)) the function takes a second or two to return and the RTC is unchanged. The only solution is to do a complete power down including disconnecting the RTC backup battery. rtc.datetime((8-tuple)) then works and returns immediately.
On today's appearance of the fault it occurred after making a minor hardware change with the board powered down and the backup battery in place. No code changes were made.
I can work round this and I'm not expecting a fix: I'm just puzzled as to the cause and wondered if anyone else had encountered it.
RTC oddity: has anyone seen this?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
RTC oddity: has anyone seen this?
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: RTC oddity: has anyone seen this?
If RTC detects a working LSE configuration it will keep it as long as Vbat (STM32F4xx) stays above a certain level (might be as low a 1V).
If for one reason the LSE is halted (and it is quite easy to halt it while modifying HW), no attempt will be made to reanimate the oscillator. Currently the only solution is to disconnect Vbat and restart the pyboard. IIRC RTC had an init method that allowed to force a reset of the LSE oscillator. I'm not sure if this is still there.
If for one reason the LSE is halted (and it is quite easy to halt it while modifying HW), no attempt will be made to reanimate the oscillator. Currently the only solution is to disconnect Vbat and restart the pyboard. IIRC RTC had an init method that allowed to force a reset of the LSE oscillator. I'm not sure if this is still there.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: RTC oddity: has anyone seen this?
I guess merely touching the components around the 32KHz crystal could stop the oscillator. That explains it: with the board powered down apart from the RTC battery I was doubtless casual in my handling.
The manual states "The LSE oscillator is switched on and off using the LSEON bit in RCC Backup domain control register (RCC_BDCR)." so it sounds like it can be forced into action. But really I think the answer is to be aware of the issue and take precautions.
Thanks very much indeed for the pointer It had me foxed as to how two separate sets of working hardware could exhibit the same fault.
The manual states "The LSE oscillator is switched on and off using the LSEON bit in RCC Backup domain control register (RCC_BDCR)." so it sounds like it can be forced into action. But really I think the answer is to be aware of the issue and take precautions.
Thanks very much indeed for the pointer It had me foxed as to how two separate sets of working hardware could exhibit the same fault.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: RTC oddity: has anyone seen this?
hmmmm... I've started to get delays again... even with this code:
and then it works fine after hard reset... still unable to catch the reason
Code: Select all
from pyb import RTC
rtc = RTC()
rtc.datetime([2017, 2, 17, 1, 22, 28, 10, 0])
rtc.datetime([2017, 2, 17, 1, 22, 28, 10, 0])
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: RTC oddity: has anyone seen this?
When you get delays has the RTC been successfully set? If the oscillator has stopped it will show an invalid date (in year 2000 IIRC). If you have an oscilloscope you could also check directly.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: RTC oddity: has anyone seen this?
as I remember it was 2000, yep