AnsweredAssumed Answered

Can't enter VLP mode on Kinetis KL14

Question asked by Luiz Fernando Schrickte on Sep 25, 2013
Latest reply on Sep 25, 2013 by Perla Andrea Moncada Fajardo

Hi,

 

I can't entre VLP mode in my Kinetis KL14. The funcion VLPModeEnable hangs in the following while (marked in blue):

 

VLPModeEnable - where the app "stops"

LDD_TError Cpu_VLPModeEnable(void)

{

  if  (ClockConfigurationID != 1U) {

    return ERR_SPEED;                  /* Very low power mode not enabled in the active clock configuration. */

  }

  if (SMC_PMSTAT == 0x04U) {           /* If the system is already in VLP mode, return */

    return ERR_OK;

  }

  /* SMC_PMCTRL: ??=0,RUNM=2,??=0,STOPA=0,STOPM=0 */

  SMC_PMCTRL = (SMC_PMCTRL_RUNM(0x02) | SMC_PMCTRL_STOPM(0x00)); /* Enable very low power mode */

  while(SMC_PMSTAT != 0x04U) {         /* Wait until in the Very Low Power run mode */

  }

  return ERR_OK;

}

 

 

Indeed I had this problem before and solved it by manually disabling a timed interrupt via a timer unit by calling TU1_Disable function before entering VLP.

 

I've been developing for a couple months and now the problem showed up again, but this time I can't figure the solution out.

 

Here is how I enter in VLP mode (I'm using User enter choice in PE options, so it is not entering VLP automatically when I set the corresponding clock configuration):

 

Entering VLP
/* important: theoretically the SetClockConfiguration function below should disable it,
* however in practice the TU1 must be disabled before it */
TU1_Disable(dev_TU1);
PWM1_Disable(dev_PWM1);

 

 

/* set clock to configuration 1 (internal clock, BLPI, 0.03125 MHz) */
Cpu_SetClockConfiguration(1);
/* enter in low power mode */
Cpu_VLPModeEnable();

 

And here is what I do when I want to return to Normal Mode:

 

Exiting VLP

/* disable Very Low Power Run Mode */

  Cpu_VLPModeDisable();

  /* set high frequency clock configuration - 16MHz */

  Cpu_SetClockConfiguration(0);

  /* reenable TU1 PE device - see comment on TU1_Disable command below */

  TU1_Enable(dev_TU1);

  PWM1_Enable(dev_PWM1);

 

I know the TU and PWM stuff should be done internally by the PE, but  this was the only way it worked before.

 

The question is: what could be preventing me from entering VLP?

 

Thank you very much!

Luiz Fernando

Outcomes