cpu/samd5x: work around errata when (re-)initializing DFLL

When a previously disabled DFLL gets enabled again, the frequency will
be incorrect. Follow the procedure outlined in the errata sheet, section 2.8.3
to work around the issue.

This fixes wake from standby.
This commit is contained in:
Benjamin Valentin 2020-03-18 23:48:08 +01:00 committed by Benjamin Valentin
parent 660b1a9b5f
commit f6139ae346

View File

@ -64,9 +64,14 @@ static void dfll_init(void)
#endif
;
OSCCTRL->DFLLCTRLB.reg = reg;
OSCCTRL->DFLLCTRLA.reg = OSCCTRL_DFLLCTRLA_ENABLE;
/* workaround for Errata 2.8.3 DFLLVAL.FINE Value When DFLL48M Re-enabled */
OSCCTRL->DFLLMUL.reg = 0; /* Write new DFLLMULL configuration */
OSCCTRL->DFLLCTRLB.reg = 0; /* Select Open loop configuration */
OSCCTRL->DFLLCTRLA.bit.ENABLE = 1; /* Enable DFLL */
OSCCTRL->DFLLVAL.reg = OSCCTRL->DFLLVAL.reg; /* Reload DFLLVAL register */
OSCCTRL->DFLLCTRLB.reg = reg; /* Write final DFLL configuration */
OSCCTRL->DFLLCTRLA.reg = OSCCTRL_DFLLCTRLA_ENABLE;
while (!OSCCTRL->STATUS.bit.DFLLRDY) {}
}
@ -152,8 +157,12 @@ void cpu_pm_cb_enter(int deep)
void cpu_pm_cb_leave(int deep)
{
(void) deep;
/* will be called after wake-up */
if (deep) {
/* DFLL needs to be re-initialized to work around errata 2.8.3 */
dfll_init();
}
}
/**