I have a custom board with an external 12MHz oscillator and the HW around it is similar to the E70 XPLD demo board. Therefore I am using the SAME70XPLD standard clock initialization in the ASF demo for the custom board.
Nevertheless, occasionally (ca. 1 of 100 times on ca. 20 boards) the board fails to boot and in the debugger I can see that the program hangs in the while() loop waiting for the PLL getting ready:
void pmc_mck_set_division(uint32_t ul_div) { : PMC->PMC_MCKR = (PMC->PMC_MCKR & (~PMC_MCKR_MDIV_Msk)) | ul_div; while (!(PMC->PMC_SR & PMC_SR_MCKRDY)); }
In most cases I cannot even step thru the code, seems the Atmel Studio/debugger/CPU is frozen.
Any idea what can cause such a problem and how to handle/recover from such a situation ?
If the PLL is not running: can this cause to freeze in the debugging ? If so then an additional timeout check in the code above does not make much sense here ?
Even if this test is successful : is it possible that the PLL "unlocks" later ? Is there kind of 'fallback' to internal RC clock if PLL clock get out of order ?
What about using the watchdog instead ? Does the watchdog work if the PLL doesn't work ?
Is it possible to check the PLL signal on external pins and if so how to configure that ?
Although this problem might be hardware related: I want to increase the stability of the board in EMR polluted environment.
What about brown-out and clock failure detection ? Any hints / experience ?
Thanks,
Jochen