AnsweredAssumed Answered

Problems putting KL03 into VLPS and reducing power consumption

Question asked by Will X on Mar 27, 2015
Latest reply on Mar 17, 2017 by Ivan Santanna

Hi all,

 

1. What I'm trying to do:

a- Put KL03 into VLPS mode

b- Switch from using the 48MHz HIRC to the 2MHz LIRC2M

c- Reduce power consumption from a few mA's to something lower than 100uA

d- Go from VLPS back to RUN mode on an SPI slave mode receive through AWIC

 

2. How I'm doing it:

a- Here are the 2 functions I am using to enter and exit VLPS:

 

void vlps_enter(void)

{

     SMC_PMCTRL = SMC_PMCTRL_STOPM(2));

     dummyread = SMC_PMCTRL;

     (void)dummyread;

 

     SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;

 

     dsb();

     wfi();

     isb();

}

 

void vlps_exit(void)

{

     SMC_PMCTRL &= ~SMC_PMCTRL_STOPM_MASK;

     SCB_SCR &= ~(SCB_SCR_SLEEPDEEP_MASK | SCB_SCR_SLEEPONEXIT_MASK);

}

 

b- Here are the 2 functions I use to switch from HIRC to LIRC2M:

 

void set_HIRC(void)

{

     MCG_MC |= MCG_MC_HIRCEN_MASK;

     MCG_C1 = MCG_C1_CLKS(0);

     MCG_C2 = 0;

     while (((MCG_S & MCG_S_CLKST_MASK) >> MCG_S_CLKST_SHIFT) != 0x00);

}

 

void set_LIRC(void)

{

     MCG_MC = 0;

     MCG_C1 = MCG_C1_CLKS(1);

     MCG_C2 = 0;

     while (((MCG_S & MCG_S_CLKST_MASK) >> MCG_S_CLKST_SHIFT) != 0x01);

}

 

c- At bootup I run this to enable HIRC and enable going into VLPS and VLLS modes:

     set_HIRC();

     SMC_PMPROT = (SMC_PMPROT_AVLP_MASK | SMC_PMPROT_AVLLS_MASK);

 

d- When the conditions to enter VLPS are met (KL03 is idle and has no pending tasks), I call the 2 functions like this:

     set_LIRC();

     vlps_enter();

     // KL03 is in VLPS here

     vlps_exit();

     set_HIRC();

 

d- My KL03 is configured as an SPI slave (with SPISWAI bit set in SPI0_C2 register) and expect that the KL03 would exit VLPS whenever an SPI transfer is coming its way

 

3. What I'm seeing:

a- With the code I have above, I measured current consumption at 0.9mA which seems very high to me in VLPS and there's no peripherals running (no ADC, no LPUART... nothing)

b- Another problem is that with this code, the KL03 never properly wakes up and processes the SPI transfer it's receiving.

c- However, if I just remove the set_LIRC() call, power consumption goes to 1.8mA and the SPI transfer works great and I have no issues (other than the high power consumption)

 

4. My questions:

a- The power numbers I'm seeing are high, is there anything else I need to change to get very low numbers in the 100uA range?

b- Any thoughts on wether the switch to LIRC2M is actually needed?

c- Any idea why if I switch to LIRC2M, the SPI wakeup doesn't work?

 

Any help is greatly appreciated.

 

Thanks!

Outcomes