KL03Z: LPTMR after Wakeup from VLLS0

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

KL03Z: LPTMR after Wakeup from VLLS0

602 Views
sarastout-grand
Contributor III

Hello,

I'm trying to use the LPTMR as a time-keeper in my application. I have it running off an external clock and coming in on RTC_CLK_IN and it runs just fine. I have read chp 32 of the manual and understand that the LPTMR should be able to keep running during VLLS0 sleep mode as long as the external clock keeps running. If I understand this correctly, that should mean that I only need to initialize the LPTMR (set-up all the registers, the interrupt, etc...) and start the timer and interrupt only on the first time through the code correct? All the setting should stay after wake-up?

I'm trying to prove this and so far what I'm seeing is that the LPTMR registers do not hold their previous values after the VLLS0 wake-up (reset). I have to redo the initialization. If they don't hold their values than how can the timer keep counting during the sleep mode?

Am I doing something wrong? Is there a trick I'm missing?

Thanks,

Sara

0 Kudos
Reply
2 Replies

446 Views
mjbcswitzerland
Specialist V

Hi

If the LPTMR has been configured and is running before VLLS0 its registers will be retained through VLLS0 and a subsequent reset.
You need only enable the clocks to the module and then you can read back the values.

I just did this on a FRDM-KL03Z with the LPTMR operating from 1kHz clock (the registers are also retained when it is done with an external oscillator).

Memory Display
0x40048038     00100582  ....

#mm 40048038 l 100583 <---------------------------enable clock to the LPTMR so that it can be read
Write - OK

#md 40040000 l 4
Memory Display
0x40040000     00000000 00000000 00000000 00000000  ................ <-----------Initlal LPTMR registers are all 0

#mm 40040004 l 1
Write - OK

#mm 40040008 l 3e7
Write - OK

#md 40040000 l 4
Memory Display
0x40040000     00000000 00000001 000003e7 00000000  ................ <--------------- configured now to run from LPO

#mm 40040000 l 1
Write - OK

md 40040000 l 4
Memory Display
0x40040000     00000081 00000001 000003e7 00000000  ................  <------------------ Now running and overflow flag is set

#lp_cnt
0x00000386

lp_cnt
0x0000013c

lp_cnt
0x000002a5

lp_cnt
0x000003da <--------------------------- LPTMR counter read and seen to be incrementing

#up


show_lp  <------------------- check the low power modes available
0 = RUN
1 = WAIT [active]
2 = STOP
3 = PSTOP1
4 = PSTOP2
5 = VLPR
6 = VLPW
7 = VLPS
8 = VLLS0
9 = VLLS1
10 = VLLS3

#set_lp 8 <---------------- Move to VLLS0

#

Hello, world... KINETIS <-------------------------------- Restart after push-button reset

#mm 40048038 l 100583  <----------------------- Enable clocks to LPTMT again
Write - OK


#md 40040000 l 4
Memory Display
0x40040000     00000081 00000001 000003e7 000003da  ................ <-------------- The register have held the last values

#lp_cnt
0x0000012a

lp_cnt
0x00000244

lp_cnt
0x0000034d

lp_cnt
0x0000004a  <--------------------------- The counter is still incrimenting

I have attached the binary in case you would like to repeat (VCOM at 115kB has menus to command these).

If you have a problem with the external clock try quickly with the LPO to see if there is a difference. It may help identify whether your issue is specific to the clock source.

Also check that you are not having a power glitch, which would indeed cause the LPTMR to stop/be reset.

Regards

Mark

0 Kudos
Reply

446 Views
sarastout-grand
Contributor III

Hi Mark,

Thanks, that was helpful. It was the clock that I was not re-enabling after wake-up.

I have noticed that the LPTMR loses track of time when it goes to sleep (VLLS0) and then wakes up. For example, I have it set to a 16s roll-over, but if I put the processor to sleep midway through the 16s count, then stay asleep for about 5 seconds, then awaken the processor with the LLWU, the LPTMR does not seem to keep time and instead rolls over about 7 seconds later than it should. This is repeatable.

Should that happen? I was really hoping that the LPTMR would keep consistent time in the background with my external clock that I never shut off. I was wondering about AWIC versus NVIC LPTMR interrupt?

Thanks,

Sara

Sara Stout-Grandy, M.Eng., Ph.D., P.Eng.

Senior Hardware Designer

20 Angus Morton Dr., Bedford,

NS, Canada, B4B 0L9

902-450-1700, x278

0 Kudos
Reply