FRDM-KL03Z: Need Help Getting into VLLS0 and waking with LPTMR!

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

FRDM-KL03Z: Need Help Getting into VLLS0 and waking with LPTMR!

583 Views
sarastout-grand
Contributor III

I'm trying to put the device into deep sleep, VLLS0 mode and then wake it from an LPTMR interrupt. I'm running the LPTMR off an external source via the RTC_CLK_IN pin which works fine in the LPTMR mode. I have the following settings to put the decide to sleep:

    //Settings to enter VLLS0 Deep Sleep Mode
    SMC_BWR_PMPROT_AVLLS(SMC, 1); // (1) Allows any VLLSx mode
    SMC_BWR_PMPROT_AVLP(SMC, 1); //(1) VLPR, VLPW, and VLPS are allowed
    SMC_BWR_PMCTRL_STOPM(SMC, 0b100); // controls entry into the selected stop mode (VLLSx) when Sleep-Now or Sleep-On-Exit mode is entered with SLEEPDEEP=1
    SMC_BWR_STOPCTRL_VLLSM(SMC, 0b000); //controls which VLLS sub-mode to enter if STOPM=VLLSx.

    //Setting for the Low Leakage Wakeup Unit
    LLWU_BWR_ME_WUME0(LLWU, 1); //Enables an internal module 0 as a wakeup source input for LPTMR
    // Enables LLWU interrupt
    INT_SYS_EnableIRQ(LLWU_IRQn);

    //Go Low Power
    SCB->SCR &= SCB_SCR_SLEEPDEEP_Msk; // Set the SLEEPDEEP bit to disable deep sleep mode - enter wait mode//
    RTC_WR_SR(RTC, 1); //Clear this register after reset
    LED1_OFF;
    LED2_OFF;
    LED3_OFF;
    POWER_SYS_SetMode(0, kPowerManagerPolicyForcible);

My LLWU interrupt handler is the following:

void LLWU_IRQHandler(void)
{
    LPTMR_BWR_CSR_TCF(LPTMR0, 1); //Clear the interrupt flag
    //This function  clears the ACK Isolation flag. Writing one to this setting when it is set releases the I/O pads and certain peripherals to their normal run mode state.
    if(PMC_BWR_REGSC_ACKISO(PMC, 1U) != 0)
        {
            PMC_BWR_REGSC_ACKISO(PMC, 1U);
        }
    SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; // Clear the SLEEPDEEP bit to disable deep sleep mode - enter wait mode//
    g_bGoToSleep = 1;
}

Nothing appears to happen with these settings. Do I have the settings wrong?

Thanks,

Sara

Labels (1)
0 Kudos
2 Replies

346 Views
mjbcswitzerland
Specialist V


Hi

Verify: "To use system OSC in VLLS0 it must be configured for bypass (external clock) operation"

As far as I am aware the LPTMR is not a LLWU module wake-up source in the KL03 (which indeed has a LLWU_ME register but no actual modules that can use it). Therefore I don't think that it can be used.
The strange thing with the KL03 user's guide is that it says that the LPTMR can be used as a wake-up source from any low leakage mode as long as it is enabled as a source but then it also says "This device has no LLWU module wake-up source and uses the external pin inputs only of LLWU_P4 and LLWU_P7 as wakeup source to the LLWU module."

If I attempt to set this in the uTasker project I get a warning that there are no wake up modules in the KL03 (nor KL05), and only a couple of pin sources can be used.

To get into the VLLS0 I do
fnSetLowPowerMode(VLLS0_MODE);

The details in this are:
SMC_STOPCTRL = (unsigned char)(SMC_STOPCTRL_VLLSM_VLLS0 | (new_lp_mode & LOW_POWER_OPTIONS));
SMC_PMCTRL = (SMC_PMCTRL_RUNM_NORMAL | SMC_PMCTRL_STOPM_VLLSx);
SYSTEM_CONTROL_REGISTER |= SLEEPDEEP;
__sleep_mode(); // enter low power mode using wait for interrupt processor state

where __sleep_mode() is
__asm__("wfi")
if KDS is being used.

I think you have forgotten to actually command the "wfi" instruction that is needed...


It is also usual to disable interrupts before setting sleep modes because it is "masked interrupts" that wake and not pending ones - and this avoids race states when a wake-up event already occurs when the processor moves to sleep, which could otherwise lose the wake-up event!

Some possible inspirations for low power modes:
http://www.utasker.com/kinetis/LLWU.html
https://www.youtube.com/watch?v=kWNlsAoMly4
https://www.youtube.com/watch?v=v4UnfcDiaE4
https://www.youtube.com/watch?v=iZEMRiDmHzw

Regards

Mark

346 Views
sarastout-grand
Contributor III

Hi Mark,

I thought I would conclude this thread. Since the last email, I learned that the LPTMR interrupt can most certainly wake the KL03 from the VLLSx sleepmodes. It needs to have an external clock running it, which is fine for my application. It doesn't make use of the LLWU module at all. I can also wake the processor from VLLSx modes with the LLWU pin interrupt. You are correct that there is no module wake-up for the KL03.

Thanks for your help!

Sara

0 Kudos