void _EntryPoint(void) {
/* Initialization code after reset */
MMCCTL1 = 0; //Memory Mapping Control
DIRECT = 0; //Direct Page Register
IVBR = 0xFF; //Interrupt Vector Base Register
ECLKCTL = 0xC0; //ECLK Control Register
//ECLK disabled
//ECLKX2 disabled
/* System clock initialization */
CLKSEL = 0; //S12XECRG Clock Select Register,Select clock source from XTAL and set bits in CLKSEL reg.
//System clocks are derived from OSCCLK
//Oscillator is disabled in Stop Mode
//Loop controlled Pierce Oscillator is selected
//IPLL keeps running in Wait Mode
//RTI keeps running in Wait Mode
//COP keeps running in Wait Mode
PLLCTL = 0x81; //S12XECRG IPLL Control Register,Disable the PLL
//Clock monitor is enabled
//IPLL is turned off
//FM off
//Fast wake-up from full stop mode is disabled
//RTI stops running during Pseudo Stop Mode
//COP stops running during Pseudo Stop Mode
//Detection of crystal clock failure forces the MCU in Self Clock Mode
POSTDIV = 0; //S12XECRG Post Divider Register,Set the post divider register
//POSTDIV[4:0] = 0b00000,POSTDIV = 0,If POSTDIV = $00 then fPLL is identical to fVCO (divide by one).
PLLCTL = 0xC1; //S12XECRG IPLL Control Register
//Clock monitor is enabled
//IPLL is turned on
//FM off
//Fast wake-up from full stop mode is disabled
//RTI stops running during Pseudo Stop Mode
//COP stops running during Pseudo Stop Mode
//Detection of crystal clock failure forces the MCU in Self Clock Mode
while(CRGFLG_LOCK == 0); //Wait until the PLL is within the desired tolerance of the target frequency
CLKSEL = 0x80; //S12XECRG Clock Select Register,Select clock source from PLL
//System clocks are derived from PLLCLK (fBUS = fPLL / 2).