I am currently having problems with a MC9S08DZ128 based board where the MCU fails to boot one out of ten times. The code generated by processor expert gets stuck in the following `while` loop, trying to wait for PLL:
| clrReg8Bits(MCGC3, 0x10U); | |
/* MCGC3: LOLIE=0,PLLS=1,CME=0,DIV32=0,VDIV=5 */
| setReg8(MCGC3, 0x45U); | /* Set MCGC3 register */ |
| while(MCGSC_PLLST == 0U) { | /* Wait until PLL is selected */ |
}
Often times the startup code fails to lock, getting stuck in the follwoing `while` loop:
| clrReg8Bits(MCGC2, 0x08U); | |
| while(MCGSC_LOCK == 0U) { | /* Wait until PLL is locked */ |
}
Whenever the MCU gets stuck on this place, a power-off/power-on or triggering the RESET pin tends to "fix" the issue by giving the MCU a chance to try again.
If I change to using FLL instead (16MHz bus frequency) the MCU starts just fine every time.