LPTMR does not always stay enabled in VLLS3

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

LPTMR does not always stay enabled in VLLS3

783 Views
joopaandentoorn
Contributor II

I am working on a low-power project with a MKL02Z32 processor, and I added a 32k crystal to the MCU in order to wake it up from VLLS3 every 10s using the OSC and LPTMR module. It is important the clock source is very stable w.r.t. temperature and age, which is why I opted for this rather than the LPO 1KHz timer. The device is configured for 12MHz cpu and 6MHz bus speed while awake.

The whole things works fine using the LPO timer instead of OSC, for any interval really. When I use the crystal, however, I need some delay after any wake-up before re-entering VLLS3, or the LPTMR will simply never trigger an interrupt to wake the device up again.

I have verified the OSC remains enabled in VLLS3. Also the LPTMR settings remain unchanged after initial settings are written after a POR (also when having this issue the settings itself are fine). I tried just scanning the LPTMR counter value to at least have counted to 1 before re-entering VLLS3, but still, for some faster modes (i.e. prescaler bypassed or low value) the LPTMR will never trigger an interrupt. If I add some artificial delay of 170ms before re-entering VLLS3, everything works fine.

The tricky part would be that the OSC resets with every wake-up and needs to be reconfigured + the isolation ackn bit has to be set. I measured the XTAL signal with an oscilloscope, there is no 'break' in the oscillation, seems to be perfectly continuous while the device is waking up.

Does anybody know of a delay or synchronization procedure (that is not described in the KL02 Sub-Family Reference Manual or Power Management for Kinetis MCUs AN4503) I might have skipped? Or did I miss something else? I do not understand why a relatively long delay of 175ms would magically solve the problem.

Labels (1)
0 Kudos
7 Replies

621 Views
joopaandentoorn
Contributor II

I should add that if I add the artificial 'sleeping-delay', the intended LPTMR interval is off by a few hundres ms as well, while the resonator is stable at 32.768KHz.

0 Kudos

621 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

I do a test with FRDM-KL02Z Sample Code Package and FRDM-KL02Z board.

In the [KL02_LowPower_Demo_freedom] demo, I make below modification to enable the LPTMR interrupt before enter into VLLS3 low power mode. The test result is there doesn't need add delay before LPTMR initialization code with enter into VLLS3 code. The LPTMR interrupt will happen as expected. 

The LPTMR clock source is from external 32.768KHz crystal.

1> Comment below code at <kl02_LowPower_Demo.c> file at line 268:

lptmr_init(5 * 1000, LPTMR_USE_LPOCLK);  // 1K clock, about 5

2> Copy below code to EnterLowPowerMode() function at <kl02_LowPower_Demo.c> file in Line 169:

lptmr_init(32767 *2, LPTMR_USE_OSCERCLK);     // 32.768K clock, about 2s

pastedImage_1.png

Customer can use above code do a quick test on your platform.

Wish it helps.


Have a great day,
Ma Hui

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

0 Kudos

621 Views
joopaandentoorn
Contributor II

Dear Ma Hui,

Thank you for your reply. I don't think the demo is applicable in this case. After a reset, the code will wait until the user specifies some stop mode, which I think will take more than 175ms in any practical case. Similarly, in our project when the MCU enter VLLS3 for the first time after an 'active period', the LPTMR also works fine one single time. Basically we keep the MCU awake as long as a user is connected and we expect commands over UART. If the user disconnects, the system goes into VLLS3 until it has to wake up to read a sensor, which happens periodically.

After waking up, the MCU performs a sensor read-out and goes back to VLLS3 right away until the next time LPTMR fires. This never happens if we don't wait for another 175ms.

On the demo board, could you try an infinite loop that wakes from VLLS3 every 2 seconds, toggles leds and immediately goes back to VLLSx, and wait for LPTMR (driven from crystal) to wake up again?

0 Kudos

621 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Wake up from VLLS3 low power mode will through the reset flow.

The MCU will following the reset flow to re-initialization the clock and used modules.

If customer had clear the LPTMR interrupt flag in LPTMR ISR routine?

I change the test code to mask the LowPowerMode_test() function and enter into VLLS3 low power mode directly in main() function. The test result is LPTMR wake up the VLLS3 low power mode as expected.

pastedImage_1.png

best regards,

Ma Hui

0 Kudos

621 Views
joopaandentoorn
Contributor II

Hi,

Yes we did clear the interrupt flag after wake-up as well as reinitialize the mcu through reset flow. Again, using the LPO clock instead of OSC gives us no problem at all.

As a last step, while using lptmr with the oscillator crystal, could you move the EnterLowPowerMode(0x8) inside the loop and remove the delay? I.e.

while(1)

{

  BLUE_TOGGLE;

  GREEN_TOGGLE;
  EnterLowPowerMode(0x8);

}

This would closest resemble our use-case. As to the rest of the code, it would not appear our firmware skips any steps.. I am puzzled why our board behaves differently.

0 Kudos

621 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I don't think place EnterLowPowerMode(0x8) in a while loop will make any difference.

Please check below test result, which I using below code:

pastedImage_1.png

When the EnterLowPowerMode(0x8) function was called, the KL02 will enter into VLLS3 low power mode.

The wake up process from VLLS3 likes a chip reset, so the code will execute from the start() function of <start.c> file.

There with no difference to place EnterLowPowerMode(0x8) function out of the while loop.

Please check attached video record about the test result.


Have a great day,
Ma Hui

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

0 Kudos

621 Views
joopaandentoorn
Contributor II

Hi Ma Hui,

Edit: Sorry I forgot the loop won't iterate because of the reset flow. Good to see it does wakeup every 2s. I wonder why ours does not.

Thank you for your help, I guess for now we will just use the LPO instead.

0 Kudos