AnsweredAssumed Answered

Kinetis MK60 Low Power System Tick

Question asked by jfs on Jul 9, 2015
Latest reply on Jul 14, 2015 by soledad

Hello,

 

I am working with MK60 processor with CW 10.4 to set it in VLPR mode without PE. I have implemented a function to set the clocks and enter in VLPR mode, that works. However it seems that the systick is lost because functions like _time_delay or _time_delay_ticks stop to work.

 

I want to update from my application the systick to be able to use it. My first approach was to use:

 

SYST_RVR =  4000000/1000; //clock used in VLPR is 4MHz (fast internal RC)

SYST_CVR = 0; //current value to zero

SYST_CSR = 0x07;

 

But it doesn't works. Can you help me please?

 

I also attach my function to change to the VLPR:

 

  SIM_SOPT1|=1<<SIM_SOPT1_OSC32KSEL_SHIFT;

  MCG_C2|=1<<MCG_C2_IRCS_SHIFT;

 

  /////////////////Switch to PBE////////////////////////////////

  MCG_C1|= MCG_C1_CLKS(0x02);

  MCG_C1&=~(MCG_C1_IREFS_MASK);

  while(((MCG_S&MCG_S_CLKST_MASK)>>MCG_S_CLKST_SHIFT)!=0x02){

  }

  MCG_C6|= 1<<MCG_C6_PLLS_SHIFT;

  MCG_C2&=~(MCG_C2_LP_MASK);

  //If we pass this while, it means we achieve PBE clock

  while(1){

  if(((MCG_C1 & MCG_C1_CLKS_MASK)>>MCG_C1_CLKS_SHIFT==0x02) && ((MCG_C1 & MCG_C1_IREFS_MASK)==0x00) && ((MCG_C2 & MCG_C2_LP_MASK)>>MCG_C2_LP_SHIFT==0x00)) break;

  }

  //////////////////////////////////////////////////////////////

 

 

  /////////////////Switch to BLPE///////////////////////////////

  MCG_C2|=(1<<MCG_C2_LP_SHIFT);

  //If we pass this while, it means we achieve BLPE clock

  while(1){

  if(((MCG_C1 & MCG_C1_CLKS_MASK)>>MCG_C1_CLKS_SHIFT==0x02) && ((MCG_C1 & MCG_C1_IREFS_MASK)==0x00) && ((MCG_C2 & MCG_C2_LP_MASK)>>MCG_C2_LP_SHIFT==0x01)) break;

  }

  //////////////////////////////////////////////////////////////

 

  SMC_PMCTRL &= ~SMC_PMCTRL_RUNM_MASK;

  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 */

  }

 

Thank you!

Outcomes