cancel
Showing results for 
Search instead for 
Did you mean: 

RTC after power cycle

andrew2
Associate II
Posted on April 06, 2015 at 17:15

I am using the STM32L1C8 with either its LSI oscillator or an attached LSE (32.768 kHz).  Either way, when I load the code through Keil the RTC module updates properly but when I do a full power cycle the RTC module doesn't seem to update.  I don't get any interrupts and when I force a read the clock stays at the default time.  I read the date right after the time, but it doesn't seem to matter because it never gets to that point on its own because it never gets an interrupt.  Once again, it only works when I first flash the code through Keil, not after a power reset.  Dose anyone have an idea of what is going on?

#rtc #keil #stm32l1
5 REPLIES 5
Posted on April 06, 2015 at 19:40

Hard to say, the general method to start/configure the RTC depends on how the system was reset, and how the RTC was previously running.

Shutdown via STANDBY, and recognizing the reset from leaving standby?

The L1 doesn't have a VBAT pin, so you really can't remove the power (cycle it) and expect anything to be running afterward.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andrew2
Associate II
Posted on April 06, 2015 at 20:42

About the power cycle, I am removing power from the MCU basically with just a switch.  I am not hoping for the time to remain or for the clock to have continued clocking (that would be impossible given no power source).  I just expect the RTC to be able to start up again once the MCU has started up and gone through its initialization, just like it does when the code is first flashed onto the MCU.

Posted on April 06, 2015 at 23:13

I'd guess you need to review your code with the mindset that the debugger is enabling/unlocking some of the peripherals you are using, or is altering/delaying the timing such that it works the first time around, but not when the part is reset.

You could instrument your code and output data via a serial port to understand the part's state in the successful and failing conditions. ie peripheral registers/clocks etc.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andrew2
Associate II
Posted on April 07, 2015 at 00:05

I just tested toggling the reset line rather than doing a full power cycle and the effects are positive.  When the MCU starts up after toggling the reset line (even after a power cycle) the RTC module starts operating.  There seems to be something special about the power on reset.

andrew2
Associate II
Posted on April 07, 2015 at 18:56

I have found a work around rather than a solution.  I check to see if the RTC module was set up properly.  If it wasn't, I generate a software reset.

I would still like to know why the RTC module is not getting set up properly on a power cycle.