unable to enter VLPR on the Kinetis KL02

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

unable to enter VLPR on the Kinetis KL02

1,147 Views
ryanlush
Contributor IV

My code is pretty mindless right now. I am using

BOARD_BootClockRUN()

To enter RUN mode and I am using

BOARD_BootClockVLPR()

To enter VLPR mode but I am getting hung on the check of the PMSTAT register. The VLPR status bit never gets set and I am hung in RUN mode. The CME bit is cleared.

Those@@ functions seems to handle all of the necessary changes to satisfy the requirements I see in the reference manual as well as AN4503 and AN4470.

Labels (1)
0 Kudos
5 Replies

578 Views
charlesasquith
NXP Employee
NXP Employee

I just pulled up a demo app and booted to VLPR successfully. When I used the RUN function first, and then the VLPR function, the transition was not successful. The RUN function is doing something that's preventing a successful transition to VLPR. Can you check to ensure that the MCG module transitions to BLPI mode successfully? A low power mode of the MCG is a requirement to enter VLPR mode, so if it's not actually entering BLPI mode, then this could be causing your holdup.

You'll need to debug and look through your registers. Can you verify that these fields are being set properly?

pastedImage_0.png

I'm not using the same board, but from my simulation it seems as though the CLOCK_BootToBlpiMode isn't ensuring a successful switch from an external clock to an internal clock, which is messing with the MCG's C1 [CLKS] value and the C1[IREFS] value and preventing it from going into BLPI mode.

0 Kudos

578 Views
ryanlush
Contributor IV

Thanks for your help Charles. I don't see what I am missing then. The reference manual says (pg 172)

The core, system, bus and flash clock frequencies and MCG

clocking mode are restricted in this mode. See the Power

Management chapter for the maximum allowable frequencies

and MCG modes supported.

Set PMPROT[AVLP]=1, PMCTRL[RUNM]=10.

Here is BOARD_BootClockVLPR

void BOARD_BootClockVLPR(void)

{

    /*

    * Core clock: 4MHz

    */

    const sim_clock_config_t simConfig = {

        .clkdiv1 = 0x00040000U, /* SIM_CLKDIV1. */

    };

    CLOCK_SetSimSafeDivs();

    CLOCK_BootToBlpiMode(0U, kMCG_IrcFast, kMCG_IrclkEnable);

    CLOCK_SetSimConfig(&simConfig);

    SystemCoreClock = 4000000U;

    SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);

    SMC_SetPowerModeVlpr(SMC);

    while (SMC_GetPowerModeState(SMC) != kSMC_PowerStateVlpr)

    {

    }

}

This function seems to do just that...

CLOCK_SetSimSafeDivs just sets the bus/flash clocks to a safe value before the switch.

CLOCK_BootToBlpiMode takes me from FEE to FBI to BLPI (required for VLPR) mode. I know it says boot but I can't see why I can't use it.

CLOCK_SetBlpiMode assumes I am already in FBI mode and I'm not, I'm in FEE mode.

CLOCK_SetSimConfig does the same thing as CLOCK_SetSimSaveDivs but I don't think it's hurting anything.

Then it's sets the SMC just as the reference manual says. I can't see what I am missing.

0 Kudos

578 Views
charlesasquith
NXP Employee
NXP Employee

Hello Ryan,

The status bit not getting set means that VLPR mode isn't successfully being entered (as you noted). I would theorize that this is because you are calling BOARD_BootClockRUN before you call BOARD_BootClockVLPR. BOARD_BootClockVLPR configures the clock for RUN mode first before going into VLPR mode, and it also configures the clock speeds to an allowable frequency range for VLPR mode. This means you ONLY need to call BOARD_BootClockVLPR, and calling BOARD_BootClockRUN prior to this would be unnecessary, and would actually configure your MCG module for an external clock instead of an internal clock. This is probably what's preventing you from transitioning into VLPR mode.

Long story short, delete your call to the BOARD_BootClockRUN function and leave the call to the BOARD_BootClockVLPR function. Hopefully this will fix your problem.

Good luck,

Charles

0 Kudos

578 Views
ryanlush
Contributor IV

But the whole point is to transition to VLPR mode during runtime when I don't need to run at full speed. Then back to RUN mode when the user wakes the device up.

Thank you,

Ryan

(sent from mobile device)

0 Kudos

578 Views
charlesasquith
NXP Employee
NXP Employee

The functions you are using are designed for starting up to a certain mode. If you want to transition to VLPR mode at some other point in time other than initialization, then I would think you might need to look at the SMC (System Mode Controller), and use that to achieve a VLPR state.

0 Kudos