AnsweredAssumed Answered

MKL14 - Problem changing system clock.

Question asked by Brian Baker on Jun 26, 2018
Latest reply on Jun 27, 2018 by Mark Butcher

On POR, I'm setting the system clock (MCGOUTCLK) to be the 4MHz High Speed Internal Reference clock. (ie. FBI mode with 4 MHz irc clock)

 

Using the following code:

-----------------------------------------------------------------

MCG_SC = 0;

 

MCG_C1 = MCG_C1_IREFS_MASK|MCG_C1_IRCLKEN_MASK;
MCG_C1 |= (1 << MCG_C1_CLKS_SHIFT);

while(MCG_S & (MCG_S_CLKST_MASK|MCG_S_IREFST_MASK) != (MCG_S_CLKST_MASK|MCG_S_IREFST_MASK));

 

MCG_C2 = MCG_C2_IRCS_MASK;

while((MCG_S & MCG_S_IRCST_MASK) != MCG_S_IRCST_MASK);

-----------------------------------------------------------------

Most of the time this is working.  But sometimes, on POR, the frequency is much faster.  It's like the POR default clock  (20.9 MHz) is still set.

 

I'm working on trying to get the system clock output so I can see the frequency when it fails.

 

Is there something I'm missing? Is there some other status bit I need to be checking?

 

Thanks.

Outcomes