RTC oddity: has anyone seen this?

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

RTC oddity: has anyone seen this?

Post by pythoncoder » Fri Jan 20, 2017 10:55 am

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.
Peter Hinch
Index to my micropython libraries.

chuckbook
Posts: 135
Joined: Fri Oct 30, 2015 11:55 pm

Re: RTC oddity: has anyone seen this?

Post by chuckbook » Mon Jan 23, 2017 8:16 pm

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.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: RTC oddity: has anyone seen this?

Post by pythoncoder » Tue Jan 24, 2017 6:50 am

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.
Peter Hinch
Index to my micropython libraries.

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: RTC oddity: has anyone seen this?

Post by kamikaze » Fri Feb 17, 2017 10:35 pm

hmmmm... I've started to get delays again... even with this code:

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])
and then it works fine after hard reset... still unable to catch the reason

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: RTC oddity: has anyone seen this?

Post by pythoncoder » Sat Feb 18, 2017 5:34 am

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.

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: RTC oddity: has anyone seen this?

Post by kamikaze » Mon Feb 20, 2017 1:29 pm

as I remember it was 2000, yep

Post Reply