AVR Tutorial: About the Clock Source

May 12, 2006
The ATMega8 AVR is shipped with it's clock source configured to the internal 1MHz RC oscillator (see: "Calibrated Internal RC Oscillator" in the datasheet p.30). This configuration works fine for many small projects where timing isn't crucial and is also convenient as it reduces parts count (1 crystal and 2 capacitors). However, you may run in to situations where you need a more accurate clock source. One example is when using the UART for serial communication. I use the serial port with the AVR quite freqently to serve as a debugging terminal and have run into problems using the internal oscillator in this case. Because of this, I have configured my AVR to use an external 8.000MHz crystal oscillator. The remaining tutorials will be tested using this 8.000MHz crystal. You can continue using your internal 1MHz clock and simply adjust the source code (#define F_CPU 1000000UL) or you can change your chip configuration to use an external crystal.

Schematic: External Crystal Oscillator

The crystal oscillator is connected to an AVR as shown above. In order to configure your chip to use an external crystal oscillator, you have to change the Fuse Bytes (see: "Fuse Bytes" in the datasheet p.223). An excelent fuse bytes how-to can be found here.

2 Comments about "AVR Tutorial: About the Clock Source"

Jon Keys
May 12, 2009 at 11:18 AM
Hi,

have you tested reliability of UART communication using 1MHz RC ? Would it work with devices such as http://www.microvga.com/ ?

Thanks
mujahid
July 22, 2008 at 04:39 AM
Hi,

I am trying to use a TQFP Package ATmega8515 with an external crystal oscillator of 12 MHz. The problem is that within the STK500 Kit the oscillator provides a clock input and it works fine. But if I try to use the same controller on the PCB crystal does not give an output frequency. I have tried to use different capacitors - the datasheet says 12-22pF. Can capacitors of more value be used.

What else could I be doing wrong

I would appreciate help

Thanks
Mujahid

Leave a Comment about "AVR Tutorial: About the Clock Source"

Your Name:
(Required)
Website URL:
(Optional)
Comment:
(No HTML. Newlines and URLs okay.)
Enter CAPTCHA:
 
 
 
 
Share