ATMega328 RC vs quartz oscillator comparison

in demonstrations by DP | 7 comments

Kenneth compares the RC oscillator found on the ATMeg328 against an external quartz crystal. As expected there is a huge difference in precision and stability between the two.

This really demonstrates how both oscillators, but particularly the internal one, are very sensitive to temperature changes around the microcontroller.  This is why my counter’s oscillator is contained in a small oven, such that it’s held at a specific elevated temperature and doesn’t change temperature along with the room.

This entry was posted in demonstrations and tagged , .

Comments

  1. dext0rb says:

    Could not resist temptation to ask…well….”whats the frequency, Kenneth?”

  2. Brian says:

    The RC is totally useable for many many applications, so the initial “why we don’t use it” seems rather silly. UARTs aren’t really that time sensitive. Even USB devices can handle use less than ideal RCs in place of XTALs (see MCP2200 datasheet). There are many applications where jitter, phase noise and frequency stability are important, but simple UART isn’t it. I would guess that the XTAL is on Arudunio for long term time stability for people who want to build clocks and the like.

    • UziMonkey says:

      USB has a sync byte at the beginning of each frame though. This is used to calibrate internal rc oscillators for each frame. Since USB has no clock pin, timing is very crucial for even half speed USB, not to mention the much faster speeds. Sometimes it’s just easier to use a crystal but with care an rc will do.

  3. Drone says:

    I agree the RC oscillator is often very useful, especially for less time critical applications where the processor needs to run slower – thereby greatly reducing power consumption.

  4. robert says:

    The problem with the ATmega AVR chips is that the factory calibration of the RC oscillator is usually pretty bad. It varies between batches. Therefore baud-rates are too far off to have an UART work reliably out of the box. It needs to be calibrated in code using the OSCCAL register. The first larger batch of chips I bought worked just fine with factory calibration + UART, the next batch simply didn’t. The last ATmega I had in my fingers ran at 8.33MHz instead of 8.00MHz.

    • Brian says:

      Well I have used a lot of AVRs and never had one that didn’t do any baud-rate I desired with no bit errors. Even with a perfect clock there are errors due to divide by N.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.