2015-04-06 08:15 AM
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 #stm32l12015-04-06 10:40 AM
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.2015-04-06 11:42 AM
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.
2015-04-06 02:13 PM
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.2015-04-06 03:05 PM
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.
2015-04-07 09:56 AM
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.