//2、 configure the MCG_C2 register
/* the RANGE value is determined by the external frequency.
Since the RANGE parameter affects the FRDIV divide value
it still needs to be set correctly even if the oscillator is not being used
*/
temp_reg = MCG->C2;
temp_reg &= ~(MCG_C2_RANGE0_MASK | MCG_C2_HGO0_MASK | MCG_C2_EREFS0_MASK);
//选择外部时钟为8M,而FLL范围为31.25 to 39.0625 kHz,则FRDIV范围为204.8~256
temp_reg |= (MCG_C2_EREFS0(1)| MCG_C2_RANGE0(1) | MCG_C2_HGO0(1));
MCG->C2 = temp_reg;
// Select external oscilator and Reference Divider and clear IREFS to start ext osc
// If IRCLK is required it must be enabled outside of this driver, existing state will be maintained
// CLKS=0, FRDIV=frdiv_val, IREFS=0, IRCLKEN=0, IREFSTEN=0
temp_reg = MCG->C1;
temp_reg &= ~(MCG_C1_CLKS_MASK | MCG_C1_FRDIV_MASK | MCG_C1_IREFS_MASK);
// 此时FRDIV=256
temp_reg |= (MCG_C1_CLKS(0) | MCG_C1_FRDIV(3)| MCG_C1_IREFS(0));
MCG->C1 = temp_reg;