sam0_common: rtc: use GCLK4 on SAMD21
The RTC expects to be clocked from a 1kHz source. Previously it would re-configure GCLK2 from 32kHz to 1kHz when used. Since GCLK2 is also used by EIC, this would break external interrupts in strange and unexpected ways. Dedicate a 1kHz clock to it to avoid the damage.
This commit is contained in:
parent
5fa234e435
commit
db2fa33660
@ -65,10 +65,8 @@ static inline void _rtc_set_enabled(bool on)
|
||||
#ifdef CPU_SAMD21
|
||||
static void _rtc_clock_setup(void)
|
||||
{
|
||||
/* Setup clock GCLK2 with OSC32K divided by 32 */
|
||||
GCLK->GENDIV.reg = GCLK_GENDIV_ID(2) | GCLK_GENDIV_DIV(4);
|
||||
GCLK->GENCTRL.bit.DIVSEL = 1;
|
||||
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN(2) | GCLK_CLKCTRL_ID_RTC;
|
||||
/* Use 1024 Hz GCLK4 */
|
||||
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN(4) | GCLK_CLKCTRL_ID_RTC;
|
||||
while (GCLK->STATUS.bit.SYNCBUSY) {}
|
||||
}
|
||||
#else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user