Page 1 of 1

RTC oddity: has anyone seen this?

Posted: Fri Jan 20, 2017 10:55 am
by pythoncoder
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.

Re: RTC oddity: has anyone seen this?

Posted: Mon Jan 23, 2017 8:16 pm
by chuckbook
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.

Re: RTC oddity: has anyone seen this?

Posted: Tue Jan 24, 2017 6:50 am
by pythoncoder
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.

Re: RTC oddity: has anyone seen this?

Posted: Fri Feb 17, 2017 10:35 pm
by kamikaze
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

Re: RTC oddity: has anyone seen this?

Posted: Sat Feb 18, 2017 5:34 am
by pythoncoder
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.

Re: RTC oddity: has anyone seen this?

Posted: Mon Feb 20, 2017 1:29 pm
by kamikaze
as I remember it was 2000, yep