Atmel AVR

The **AVR** microcontroller architecture was developed by Atmel in 1996. It is based on the Harvard microcontroller architecture. The AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to one-time programmable ROM, EPROM, or EEPROM used by other microcontrollers at the time.

Many people think that AVR stands for **A**lf (Egil Bogen) and **V**egard (Wollan)'s **R**isc processor".

This architecture replaces older MCS-51 architecture. One machine cycle of MCS-51 takes 12 clock cycles and most of  instructions are executed in one machine cycle.

AVR microcontrollers (MCUs) can execute most of instructions in single machine cycle too, but one machine cycle takes only one clock cycle. Performance per clock cycle is 12 times higher with AVR.

The core has 32 general purpose registers directly connected to ALU. It allowing two independent
registers to be accessed and instruction with them executed in one machine cycle.

## Basic families

**tinyAVR**
- 0,5-8 kB program memory
- up to 0,5 kB SRAM
- up to 0,5 kB EEPROM
- up to 20 MHz
- 6-32 pin package

**megaAVR**
- 4-256 kB program memory
- 0,5-16kB SRAM
- 0,5-4 kB EEPROM
- up to 20 MHz
- 20-100 pin package

**XMEGA**
- 16-384kB program memory
- 2-32 kB SRAM
- external Bus Interface for up to 16M bytes SRAM of SDRAM
- 1-4 kB EEPROM
- up to 32 MHz
- 44-100 pin package

## Features

Every AVR has some input/output ports. The port has up to 8 physical pins on its package. Every pin can be configured as input or output. If a pin is used for input, it can turn on built-in pull-up resistors through register PORTx. If a pin is configured as output, it can handleup to 40mA of load per pin and max 100mA for all pins on the port.

**A/D converter**
- 10-bit (tinyAVR, megaAVR) with multiplex up to 8 channels
- 12-bit (XMEGA) with multiplex up to 16 channels

**Timers/counters (8-bit or 16-bit)**
- Users can configure it asi PWM, counter or timer.
- In simple PWM mode, the counting register runs without stopping and is compared to another register. If the counting register is higher than second register pin Ocx is set to „1“. In other time is pin Ocx set to „0“.
- Counter have some external source like photo sensor and can count amount of people which pass photo sensor.
- Timer gives pulses in exact time. It is used for programing clock applications.

**TWI – Two Wire Interface**
This uses the same protocol as I<sup>2</sup>C and can be used as I<sup>2</sup>C interface

**UART/USART**
The UART can be used for RS232/RS485 communication.

**SPI - Serial Peripheral Interface**
- very fast serial bus which is used for data transfer of communication with devices
- you can burn/read program into/from program memory or EEPROM through this bus

**USI - Universal Serial Interface**
- used for two or three wire synchronous data transfer

**JTAG**
- interface for online debugging

**D/A converter**
- 12-bit (only XMEGA) with multiplex up to 2 channels

## Related pages

- Arduino

## Other websites

- Primary Sources
- Atmel AVR homepage
- AVR Freaks community
- Atmel AVR Serial Port Programmer
- Atmel AVR USBasp USB Port Programmer
- Arduino community
- , numerous AVR links
- Why you need a clock source for the AVR?
- AVR Basics - AVR guide for beginners