12.3.5 Tuning the Internal High-Frequency Oscillator

Tune the output frequency of the OSCHF either manually or automatically against external inputs.

Manual Tuning

Disable the Automatic Oscillator Tune (AUTOTUNE) bit field in the Internal High-Frequency Oscillator Control A (CLKCTRL.OSCHFCTRLA) register by writing '0' to the bit field. Tune the output frequency of the OSCHF manually by writing the Oscillator Frequency Tuning (TUNE) bit field in the Internal High-Frequency Oscillator Frequency Tune (CLKCTRL.OSCHFTUNE) register.

Auto-Tune Against an External Crystal Oscillator

The OSCHF output frequency can be calibrated by automatic tuning against XOSC32K. Enable the auto-tune by writing the 32K setting to the AUTOTUNE bit field in the OSCHFCTRLA register, locking the OSCHFTUNE register, and no manual tuning is possible. The OSCHFTUNE register is updated with the latest auto-tuned value when AUTOTUNE is disabled.

Figure 12-3. OSCHF Auto-Tune Block Diagram

Refer to the Electrical Characteristics section for details.

Auto-Tune Against Start-of-Frame signal

The output frequency of the OSCHF must be tuned against the Start-of-Frame (SOF) signal from the USB when using the USB peripheral.

Enable the auto-tune by writing the SOF setting to the AUTOTUNE bit field in the OSCHFCTRLA register, locking the OSCHFTUNE register, and no manual tuning is possible. The SOF auto-tune has two options for algorithm selection, Binary Search and Incremental Search, respectively. These can be chosen by writing the ALGSEL bit in the OSCHFCTRLA register. Using the binary search algorithm may temporarily change the oscillator output frequency up to half the tune range, affecting running timing critical asynchronous peripherals, such as the USART or a timer generating PWM waveforms. The OSCHFTUNE register is updated with the latest auto-tuned value when AUTOTUNE is disabled.

Figure 12-4. OSCHF Start-Of-Frame Auto-Tune Block Diagram

Refer to the USB section for details.