Typical circuits of AVR microcontrollers for fast start

All AVR microcontrollers contain same AVR core which is RISC architecture. So program or its parts written for one AVR will work in another AVR microcontroller. So it is enough to learn one AVR MCU and you can work with all other.

To make circuit work normally you need to follow several conditions: apply power supply, clock device, organise reset after power-up and connect peripherals to I/O. All this information you can find in data-sheets. By the way, Atmel datasheets are very well organised and unified. They are easy to read and there is no stress when changing AVR microcontrollers because you intuitively know where to find required information without pain. If you take like NXP ARM MCU documentation you will see how hard can it be to access required information, because datasheets are poorly organized while microcontrollers are really good. But leave this for another topic.

Lets get back to AVR. Lets take Atmega8 microcontroller. This is a “work horse” MCU as it is simple but powerful with most requires features and peripherals. It has following pins:

  • VCC, AVCC – power supply;

  • GND – ground;

  • PB0-PB7 – port B I/O;

  • PC0-PC6 – port C I/O;

  • PD0-PD7 – port D I/O;

  • AREF – analog reference pin for A/D converter.

Each port pin has programmable alternative functions. In datasheets you may see two types of Atmega8 chips: Atmega8-16 and Atmega8L-8. First one may be powered with voltages from 4.5 to 5.5V and clock frequency range is 0..16MHz while second one can be powered with voltages from 2.7 to 5.5V but maximum clock frequency may be 8MHz. If you need maximum performance you should select Atmega8 power with 5V and select frequency up to 16MHz. But if you want to save power then select Atmega8L and use low frequencies 1..8MHz.

Powering AVR microcontrollers

Atmega8 have two types of power pins: VCC, GND for digital part and AVCC and GND for analog part. This is done to minimize interference noises. Inside chipe analog and digital GND parts are connected via 0.7ohm resistor.

Capacitors must be ceramic and mus be as close to chip pins as possible. If there internal ADC is used, then AVCC should be powered vial LC filter:

To reduce overall noises it is better to power both VCC and AVCC via LC filter. If ADC isn't used, then you should connect AVCC to VCC pin.

AVR microcontrollers don't tolerate voltages over 6V. Also there is maximal tolerable current that can flow in VCC and GND. Generally it shouldn't exceed 200mA. In order to protect and stabilize it is better to use low power voltage regulator like 78L05.

AVR Reset on power-on

In order to set up internal register properly to their initial state after power is applied, there is reset on power-on needed. Atmega8 have several options:

  • Internal resetwhen voltage reaches 1.4...2.3V;

  • Reset from Brown-Out when voltage drops lower limit;

  • External reset with “0” signal to RESET pin;

  • WatchDog timer reset.

If power supply voltage is stabilized and voltage is applied as a “step function”, then external elements are not needed because internal Power-On initiates MCU. This is ok for Hobby circuits, but industrial equipment may dissipate noises to supply circuits, so there are needed external reset circuitry.

AVR microcontrollers have advanced protection from short time brown-out and black-out events. Internal BOD(Brown-Out Detector) analyses continuously VCC voltage and generates reset if one of two conditions are met: 2.7 or 4V with 0.1V hysteresis.

BOD(Brown-Out Detector) can be enabled by programming fuses BODEN and BODLEVEL.

Sometimes there are also external voltage level detectors used.

Watchdog timer may be enabled by programming fuse WDTON(Watch Dog Timer On). This starts special timer which analyses processor state. If processor hangs then in some defined time(17ms..2.2s) it sends reset signal.

If watchdog is on it MCU require additional current about 50uA. So if device is battery operated then its is better to disable it.

And last but not least is external reset.

External reset occur if “0” level is applied to RESET pin for 1.5us. Reset button usually is connected to RC circuit (also ISP reset signal). During reset power consumption of AVR doubles(from 5-15mA to 20-25mA). This also should be taken in account when designing devices with limited power. In many AVR circuits there is no button and capacitor. This is ok, just you have no option to reset MCU or you have to do this in software.

Clocking AVR

AVR microcontrollers have to synchronized. This can be in many ways. Many options lead to mistakes. Read about clock sources and fuse settings here. Generally speaking Atmega8 can by synchronized with following:

  • Crystal oscillator 0.9..16MHz;

  • Ceramic resonator0.4..0.9MHz;

  • Low frequency crystal 32786Hz;

  • Internal RC generator 1; 2; 4; 8MHz;

  • External RC circuit 0.4..12MHz;

  • External pulse generator 0..16MHz.

As you see you have many options. Which one to select depends on many parameters and what requirements are. If you want stabile frequency – use crystal. If you need less external elements – use internal RC. Read more about microcontroller oscillators. Sometimes you may need to have option to adjust frequency manually by using potentiometer. Then it is best to use external RC circuit:

If CKOPT fuse is programmed(CKOPT=0) - you don't need external capacitor C1. As internal Co will be used. Using potentiometer you have option to control frequency manually. You can calculate frequency by formula:


so if R1=33kΩ and C1=22pF, then frequency Ft=0.46MHz.

In battery operated devices it is good to use low frequency crystal 32768 as it require low current(about 80uA) If CKOPT fuse is programmed, then internal optimized for this frequency capacitors are connected. Of course device will vork with different frequencies like 30 – 300kHz:

For more information read clock sources and fuse settings, microcontroller oscillators and don't forget datasheet.