Clock Sources

The megaAVR microcontrollers allow multiple clock options for system clock, selectable from the external RC oscillator, crystal oscillator, external clock, and calibrated internal RC oscillator. The clock source is selectable by fuses (CKOPT and CKSEL[3:0]) and cannot be changed by software.

Figure 1. ATmega128 Clock – Block Diagram

The AVR Dx family uses a different clock system compared to the megaAVR family. Even if the default oscillator is selected using fuses, this can be safely changed by software during normal operation. The frequency of the internal High-Frequency oscillator (OSCHF) is also selectable by software to 1, 2, 3, 4 MHz, and multiples of 4, up to 24 MHz. For more details, see the CLKCTRL - Clock Controller section from the device data sheet.

Figure 2. AVR® Dx Clock – Block Diagram

Additionally, the AVR Dx devices provide a Phase-Locked Loop (PLL) that allows clock multiplication by 2x or 3x (maximum frequency 48 MHz) and can serve as input for the Timer/Counter type D (TCD).

Not all AVR Dx devices provide the option for a High-Frequency crystal oscillator (XOSCHF), but the accuracy of the AVR Dx’s internal High-Frequency oscillator (OSCHF) can be improved using the built-in auto-tune logic combined with the 32.768 kHz crystal oscillator. This is done by comparing the internal 1 MHz clock with a reference derived from the 32.768 kHz crystal:

Figure 3. OSCHF Auto-Tune Block Diagram

Note: For details about how to use the auto-tune feature, refer to TB3234 - Internal High-Frequency Oscillator Calibration Using the Auto-Tune Feature.