AVR is a series of 8-bit RISC microcontrollers produced by Atmel. AVR follows Harcard architecture and therefore has separate program and data memory. For the program it has an internally overwriteable flash memory, for data there are static (SRAM) and EEPROM memory. Controller's frequency is usually up to 16 MHz and performance is almost 1 MIPS per 1-megahertz cycle.
The production of AVR microcontrollers began in 1997 and by now AVR is one of the most popular controllers with hobby electronics engineers. Thanks to cheap developing tools, the diversity of peripherals in a single package and low power consumption the initial success was gained. Today, there is another reason for choosing AVR: the massive amount of information and tutorials built up over the years. The AVR technology is inevitably aging, but to stay in competition Atmel is also making new AVR microcontrollers with more up-to-date peripherals and 16- and 32-bit buses, first of which are from the 8-bit compatible XMega series and the latter from the brand new AVR32 series.
Based on the type of the application, there are several types of AVR microcontrollers, each with a different configuration. Most of the AVRs belong to the megaAVR series, which have a large program memory. To balance off the megaAVR series, there is also the tinyAVR series, which have smaller packages and less features. In addition to these, there are also different series of microcontrollers designed specifically for controlling USB, CAN, LCD, ZigBee, automatics, lighting and battery-powered devices.
The following text describes the main features of megaAVR series microcontrollers, using one of the most popular controllers in this series, ATmega128, as an example. This controller is also in the HomeLab kit. Generally, all the AVR series microcontrollers' register names, meanings and usage is organized in a way to enable the examples also to be used with other controllers by making only slight changes. The main differences are in the peripherals. The code samples of this introduction are written in assembler and C, using AVR LibC.
Like all other controllers, the AVR is also packaged in some standard shell. The traditional casing is DIP (also called DIL). DIP is a so-called casing on legs - all the pins extrude as legs, about 5 mm in length, from the black plastic casing. DIP casing is a sensible choice for hobby applications and prototypes, because there are cheap sockets available for it, so the microcontroller can easily be replaced, should it happen to malfunction or die. The legs are also a disadvantage of the DIP casing, because it requires holes to be drilled in the circuit board.
The surface mount casings (SMT, also called SMD) are much more compact, because their pins are designed to be soldered straight to the board without the need to penetrate it. SMT microchips are in thin, coin-sized rectangular casings with pins about 1 mm long. A more precise hand and better tools are required for soldering SMT chips.
AVRs are available in both DIP and SMT casings. The layout of the pins is designed as logically and electrically even as possible. For example, on larger chips, the ground and supply pins are located on several sides of the microcontroller, the pins for an external oscillator are near the ground pin, the bus pins are in numerical order, the communication pins are next to each other etc. AVRs digital pins are compatible with TTL/CMOS standard voltage levels. At 5 V supply voltage, 0 to 1 V means logical zero, which is also called zero, null, 0, low, ground, or GND. At the same supply voltage, 3 to 5.5 V means logical one, also called one, 1, high. This type of wide voltage range only applies to the inputs - the output voltage on a pin with no load is still 0 V or near supply voltage, depending on the state of the pin. The allowed analog voltage level on the ADC channels is 0 to 5.5 V.
To better understand the following examples on ATmega128, there is a pinout schematic of ATmega128 (SMT package) below. Next to each pin, is a text with its number, primary function and secondary (alternate) function in brackets. Supply pins are GND and VCC. AVCC and AREF are analog-to-digital converter's supply and reference voltage pins. XTAL1 and XTAL2 are for connecting an external crystal oscillator, resonator or clock generator. Pins PB0 to PG4 mark the bits of input-output buses. The secondary functions of pins are discussed in the corresponding chapters.