Gary
You may find that the problem is that your reference code uses an external oscillator and your HW uses a crystal - the configuration is quite different for these two cases. See the following for general MCG overview which may give a bit more practical insight than the user's manual: µTasker MCG Configuration Support
As reference, the following is the way to configure the K20F120 to generate 120MHz core frequency from 24MHz crystal so that you can compare with what you presently have:
MCG_C2 = (MCG_C2_RANGE_8M_32M | MCG_C2_GAIN_MODE | MCG_C2_EREFS | MCG_C2_LOCRE0); // select crystal oscillator and select a suitable range
MCG_C1 = (MCG_C1_CLKS_EXTERN_CLK | MCG_C1_FRDIV_1024); // switch to external source (the FLL input clock is set to as close to its input range as possible, although this is not absolutely necessary if the FLL will not be used)
while ((MCG_S & MCG_S_OSCINIT) == 0) {} // loop until the crystal source has been selected
while ((MCG_S & MCG_S_IREFST) != 0) {} // loop until the FLL source is no longer the internal reference clock
while ((MCG_S & MCG_S_CLKST_MASK) != MCG_S_CLKST_EXTERN_CLK) {} // loop until the external reference clock source is valid
MCG_C5 = ((CLOCK_DIV - 1) | MCG_C5_PLLSTEN0); // now move from state FEE to state PBE (or FBE) PLL remains enabled in normal stop modes
MCG_C6 = ((CLOCK_MUL - MCG_C6_VDIV0_LOWEST) | MCG_C6_PLLS);
while ((MCG_S & MCG_S_PLLST) == 0) {} // loop until the PLLS clock source becomes valid
while ((MCG_S & MCG_S_LOCK) == 0) {} // loop until PLL locks
SIM_CLKDIV1 = (((SYSTEM_CLOCK_DIVIDE - 1) << 28) | ((BUS_CLOCK_DIVIDE - 1) << 24) | ((FLEX_CLOCK_DIVIDE - 1) << 20) | ((FLASH_CLOCK_DIVIDE - 1) << 16)); // prepare bus clock divides
MCG_C1 = (MCG_C1_CLKS_PLL_FLL | MCG_C1_FRDIV_1024); // finally move from PBE to PEE mode - switch to PLL clock
while ((MCG_S & MCG_S_CLKST_MASK) != MCG_S_CLKST_PLL) {} // loop until the PLL clock is selected
Where
#define CLOCK_DIV 3 // input must be divided to 8MHz..16MHz range (/1 to /8 for 120MHz parts)
#define CLOCK_MUL 30 // the PLL multiplication factor to achieve operating frequency of 120MHz (x16 to x47 possible - divided by 2 at VCO output)
#define SYSTEM_CLOCK_DIVIDE 1 // 120/1 to give 120MHz
#define BUS_CLOCK_DIVIDE 2 // 120/2 to give 60MHz
#define FLEX_CLOCK_DIVIDE 3 // 120/3 to give 40MHz
#define FLASH_CLOCK_DIVIDE 5 // 120/5 to give 24MHz
Noting
MCG_C6_VDIV0_LOWEST is 16 for the K20F120 part in question.
Regards
Mark
Kinetis: µTasker Kinetis support
K20: µTasker Kinetis TWR-K20D72M support / µTasker Kinetis FRDM-K20D50M support / µTasker Kinetis TWR-K20D50M support / µTasker Teensy3.1 support
For the complete "out-of-the-box" Kinetis experience and faster time to market