AVR Tutorial: About the Clock Source

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.
Did you enjoy AVR Tutorial: About the Clock Source? If you would like to help support my work, A donation of a buck or two would be very much appreciated.
blog comments powered by Disqus
Linux Servers on the Cloud IN MINUTES