How to Keep RTC Active during Wake from VLLS3?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Keep RTC Active during Wake from VLLS3?

584 Views
james5
Contributor I

Hello,

I have a project targeting the MKL03Z32 that goes into deep sleep VLLS3 and wakes from LLWU_P4.  I want to keep accurate track of time, so the RTC unit is enabled during both wake and deep sleep.  This all seems to work as expected.

The only hiccup is that it seems that when the micro wakes from VLLS3 it turns of the RTC bit in SIM->SCGC6 which turns off the clock to the RTC module.  As a result, the RTC stops.

I currently set a bit in the System File Register (which keeps state through this wake event) that is set once the RTC is configured the first time and then I manually turn on the RTC bit in SIM->SCGC6 as one of the first things in the main loop.

This does function but the RTC is turned off for a small amount of time every time it wakes and thus my timing is accumulating error.  Is there a way to keep the RTC clock enabled during a wake event?

If it matters, I'm using an external crystal as the source for the RTC.

Thanks in advance,

James

0 Kudos
3 Replies

477 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi James,

According to the description of "2.5.6 Exiting VLLS3, VLLS2, VLLS1, or VLLS0" in AN4503:
If the oscillator has been kept running in VLLS1,VLLS2, or VLLS3, it must be re-configured before ACKISO is written (unless it was configured in RTC OSC).

Exiting VLLS3, VLLS2, VLLS1, or VLLS0.png

Please check if it was caused by this.

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

477 Views
james5
Contributor I

Thanks Robin, that may be what I'm running into.  It is unclear though (at least to me) what the phrase "unless it was configured in RTC OSC" means.  I do have the RTC running during VLLS3 in order to keep accurate time.  But this device doesn't have the dedicated RTC OSC pins EXTAL32 and XTAL32.  So I am using the system OSC pins ETAL0 and XTAL0 with a 32.768Khz clock to drive the clock into the RTC module.  So does this mean I need to re-configure the clock or not?  Below is the clock configuration of the chip just before going to VLLS3.

Annotation 2019-06-25 085856.png

If I do need to re-configure the clock, doesn't that mean that the RTC is going to be slightly inaccurate as it briefly turns OFF during wake and then is re-enabled a (very) short time later.  But it doesn't take much to cause a significant error over multiple wakeup events.

Thank you very much,

James.

0 Kudos

477 Views
james5
Contributor I

To anyone else who stumbles across this, I have confirmed with NXP that the RTC clock is gated on wake from VLLS3 (maybe from other states) to RUN for exactly 125ms (4096 cycles of 32.76Khz clock).  So to keep more accurate time over multiple wake up events you need to add one to the RTC seconds register once every 8 times the micro goes through this wake up sequence.

James.

0 Kudos