Bumping PMC_MAIN_OSC_STARTUP_DELAY to solve slow clock on some devices, thanks @iceman1001!

This commit is contained in:
Philippe Teuwen 2019-10-15 18:02:19 +02:00
commit 0877802ded

View file

@ -19,12 +19,15 @@ void mck_from_slck_to_pll(bool cold) {
// worst case scenario, with MAINCK = 16MHz xtal, startup delay is 1.4ms // worst case scenario, with MAINCK = 16MHz xtal, startup delay is 1.4ms
// if SLCK slow clock runs at its worst case (max) frequency of 42kHz // if SLCK slow clock runs at its worst case (max) frequency of 42kHz
// max startup delay = (1.4ms*42k)/8 = 7.356 so round up to 8 // max startup delay = (1.4ms*42k)/8 = 7.356 so round up to 8
// UPDATE:
// we observed on 10% of the devices very wrong initial slow clock RC TIA measures.
// Bumping delay to 16 helps fixing the issue even on the most screwed RC.
// enable main oscillator and set startup delay if cold boot // enable main oscillator and set startup delay if cold boot
if (cold) { if (cold) {
AT91C_BASE_PMC->PMC_MOR = AT91C_BASE_PMC->PMC_MOR =
AT91C_CKGR_MOSCEN | AT91C_CKGR_MOSCEN |
PMC_MAIN_OSC_STARTUP_DELAY(8); PMC_MAIN_OSC_STARTUP_DELAY(16);
} else { } else {
AT91C_BASE_PMC->PMC_MOR = AT91C_CKGR_MOSCEN; AT91C_BASE_PMC->PMC_MOR = AT91C_CKGR_MOSCEN;
} }