12.3.1 Initialization
To initialize a clock source as the main clock, follow these steps:
- Optional: Force the clock to always
run by writing the Run Standby (RUNSTDBY) bit in the respective clock source CTRLA
register to ‘
1
’. - Configure the clock source as needed in the corresponding clock source CTRLA
register and, if applicable, enable the clock source by writing a
‘
1
’ to the Enable bit. - Optional: If RUNSTDBY is ‘
1
’, wait for the clock source to stabilize by polling the respective status bit in CLKCTRL.MCLKSTATUS. - The following sub-steps need to be
performed in an order such that the main clock frequency never exceeds the allowed
maximum clock frequency. Refer to the Electrical Characteristics section for
further information.
- If required, configure the
clock source frequency by writing to the Prescaler Division (PDIV) bit field
and enable the main clock prescaler by writing a ‘
1
’ to the Prescaler Enable (PEN) bit in CLKCTRL.MCLKCTRLB. - Select the configured clock source as the main clock in the Clock Select (CLKSEL) bit field in CLKCTRL.MCLKCTRLA.
- If required, configure the
clock source frequency by writing to the Prescaler Division (PDIV) bit field
and enable the main clock prescaler by writing a ‘
- Wait for Main Clock to change by polling the Main Clock Oscillator Changing (SOSC) bit in the Main Clock Status (CLKCTRL.MCLKSTATUS) register.
- Optional: Clear the RUNSTDBY bit in the clock source CTRLA register.