Electronic – What’s the difference between all of the Atmega328p clocking options

atmegamicrocontrolleroscillator

Reading through the data sheet of Atmel's Atmega328p microcontroller, I had heard reference of an internal 127kHz RC oscillator. This being the default oscillator if no external crystal/resonator was configured.

However, after reading through the data sheet some more, it states that device comes shipped with a 8Mhz internal oscillator… Which confused me, does it feature both?

I then started reading into all of the possible clocking options, and there were some terms that I was unfamiliar with. Referring to page 28 of the Atemga328p manual (http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf), it lists all of the clocking option.

Of those clocking modes, what are the differences between low power crystal oscillator, full swing crstal oscillator, low frequency crystal oscillator, and calibrated internal RC oscillator?

I appreciate any help!

Best Answer

When looking at the system clock input options, it is a trade-off of power, frequency and precision.

For a master oscillator above 8MHz (provided the device speed grade is adequate), an external crystal is necessary, but if that is not an issue, the internal RC oscillator is accurate enough for many applications, but if you care about timings that must be precise, then this is probably not the best option:

ATMega328p RC calibration

The 10% variation in clock frequency may be too wide for precision timing requirements, for which you would more normally use a crystal, with a typical accuracy of perhaps 50 to 100 ppm or tighter if you are prepared to pay a premium for a device.

True, you could do a calibration yourself, but this would be necessary for every single device, and it still only yields 1% accuracy, not generally sufficient in precision timing.

There is an option for a low power external crystal, but the frequency range is more limited than the full drive device (16MHz vs 20MHz)and the datasheet has this to say in section 9.3:

This Crystal Oscillator is a low power oscillator, with reduced voltage swing on the XTAL2 output. It gives the lowest power consumption, but is not capable of driving other clock inputs, and may be more susceptible to noise in noisy environments.

In these cases, refer to the ”Full Swing Crystal Oscillator” on page 30

The datasheet clearly states that if this is an issue, you should look at the full swing crystal oscillator (which will typically be the highest power) but has a drawback on system Vcc range:

This Crystal Oscillator is a full swing oscillator, with rail-to-rail swing on the XTAL2 output. This is useful for driving other clock inputs and in noisy environments. The current consumption is higher than the ”Low Power Crystal Oscillator” on page 29. Note that the Full Swing Crystal Oscillator will only operate for VCC = 2.7 - 5.5 volts.

The low frequency crystal oscillator is designed for use at 32.768kHz (very slow but often adequate in low power, low frequency sensing applications)

The designer is given the choice to make appropriate trade-offs of accuracy, power and frequency range by this arrangement (which is common in many newer families of microcontrollers)