AnsweredAssumed Answered

FRDM-KL26Z - can't moving from FEI to PEE mode

Question asked by Maxime Dolberg on Jun 1, 2014
Latest reply on Jun 2, 2014 by Mark Butcher

Hello everybody !

 

I'm starting to use the Freedom Board KL-26Z and I would like to manually initiate the clock (without the help of PE). To do that, I follow the step by step example 1 from the KL26Z reference manual (p.416 : "24.5.3.1 Example 1: Moving from FEI to PEE mode: External Crystal = 4 MHz, MCGOUTCLK frequency = 48 MHz"). For my application, the external crystal run at 8MHz.

 

But I'm stuck at step 1.d : "loop until IREFST = 0". When I start debugging IREFST bit from MCG status register is alway set and never clear. 

 

Am I missing something ?

 

the actual code :

 

int main(void)

{

//init MCU OSC

  MCG_C2 = 0x2C;

  MCG_C1 = 0x98;

  while(!MCG_S_OSCINIT0_MASK);

  while(MCG_S_IREFST_MASK); // <-- I'm Stuck here !!

  while(!(MCG_S_CLKST_MASK == 0x2));

  MCG_C5 = 0x02;

  MCG_C2 |= 0x02; // LP=1,FBE -> BLPE mode 

  MCG_C6 = 0x40;

  MCG_C2 &= 0xFD; // LP=0,BLPE -> PBE mode

  while(!MCG_S_PLLST_MASK);

  while(!MCG_S_LOCK0_MASK);

  MCG_C1 = 0x18;

  while(!(MCG_S_CLKST_MASK == 0x3));

 

  printf("end of init");

  return 0;

}

 

 

 

Outcomes