6 Configure OSCHF to Run at 24 MHz and Activate/Deactivate the Auto-Tune Feature

The 24 MHz clock is the highest base frequency for the internal high-frequency oscillator.

The following line of code sets the clock speed of OSCHF to 24 MHz:

_PROTECTED_WRITE (CLKCTRL.OSCHFCTRLA, CLKCTRL_FREQSEL_24M_gc);

The following line of code for sets the OSCHF clock speed to 24 MHz and enables the auto-tune feature:

_PROTECTED_WRITE (CLKCTRL.OSCHFCTRLA, ((CLKCTRL_FREQSEL_24M_gc)|(CLKCTRL_AUTOTUNE_bm)));
Figure 6-1. 24 MHz Clock Without Tuning
Figure 6-2. 24 MHz Clock After Auto-Tune

The figures above show the error was within the tolerated values to be corrected, thus the tuning register remained unchanged.