Microchip AVR

from Wikipedia, the free encyclopedia
AVR family logo
ATmega, ATXmega and ATtiny microcontrollers

Microchip AVR (formerly Atmel AVR) is an 8-bit microcontroller family from the US manufacturer Microchip . The controllers of this family are also widely used by hobby users because of their simple structure, easy programming, free development tools and availability in DIP housing designs. The microcontroller family was developed by the former US company Atmel; according to the company, the name AVR is meaningless.

The types are divided into groups

  • ATxmega: very powerful processors with DMA capabilities, etc.
  • ATmega: large AVR controller with up to 256  KiB flash memory in 28 to 100-pin housings and with an integrated hardware multiplier.
  • ATtiny: smaller AVR controller with up to 16 KiB flash memory in 6- to 32-pin housings.
  • AT90USB: ATmega with integrated USB controller
  • AT90CAN: ATmega with CAN controller
  • Special types: some special models, e.g. B. to control battery chargers, LC displays and for motor or light controls.
  • AT90S: outdated types, the "classic" AVRs

Under the name AVR32 Atmel has a 32-bit - RISC - architecture with DSP and - SIMD developed functionality. Despite the similarity of names and logos, the two architectures have little in common.

Programming interface

The AVRISP mkII ISP programmer from Atmel

Almost all types can be programmed via SPI via an ISP (AVR ISP, In-System Programmer ), which can be connected to the serial , parallel or USB interface of a PC via a simple programming adapter . The specialty lies in the possibility of not having to remove the processor from the target circuit. Instead, it can be reprogrammed when it is installed. An AVR chip can also be programmed using an HV programmer (high voltage programmer), the voltage of which is 12 V. This is necessary if the reset pin required for the ISP interface has been deactivated by setting the fuse bits - for example to use it as an I / O pin due to the lack of free pins - and the chip can no longer be programmed via an ISP .

Newer types also have a debug interface which, in the case of smaller controllers (ATtiny series and 32-pin ATmega family), only requires the reset line in addition to the supply lines ( debugWIRE ). With larger controllers of the ATmega family, on the other hand, it is easier to do without several pins (6), so that a JTAG interface is used here. With this, a program downloaded into the microcontroller can be examined in a specific hardware environment using additional hardware / software according to the IEEE standard 1149.1 , and any programming errors can be removed (debugged).

RISC architecture

One advantage over other microprocessor families is that, thanks to the RISC architecture, most register commands can be processed within one system cycle, with the exception of jump and multiplication commands and access to the memory interface (including RAM and I / O ports). Thus this architecture is very fast compared to others.

Thanks to the hardware design based on high-level languages ​​such as C , even compilers can generate very efficient code; the developer does not necessarily have to go to assembler level. The design of the ATMEGA8 was already optimized during the development of the chip for C compilers.

However, as with many other microprocessors with integrated program memory , the binary program code is executed directly from the flash memory . As a result, especially with the chip versions for low supply voltages of less than 3.3 V, the processor core has comparatively low maximum clock rates of mostly less than 10 MHz. Since the frequency corresponds almost 1: 1 to the IPS , a maximum of 10 MIPS can be achieved. It is not possible to operate the internal processor core using a PLL with a clock rate that is higher than that of the external clock. This restriction is due to the integration of the flash memory technology. For comparison: microprocessor architectures like the Blackfin , which copy the program code from the non-volatile flash memory to an internal SRAM memory before execution , have clock rates of the processor core of over 500 MHz with supply voltages of the CPU core of less than 2 V at in about the same low power consumption.

Instruction set

Number of opcodes of the AVR families
model Number of commands
AT90S1200 52
AT90xxxx ("Classic") 62
ATtiny to 123
ATmega 130-135
ATXMega from 142

In contrast to the PICmicro processors, the AVR instruction set was kept compatible across all models - apart from the AT90S1200 with a restricted instruction set and the ATmega with a slightly expanded instruction set. However, there are minor differences in the scope of commands due to different flash sizes, bootloader support, multiplication commands (from Mega), the hardware equipment, etc.

The AVR processors are designed for the efficient execution of compiled C code. Even before the AVR core was completed, the development of a C compiler began in order to identify potential for optimization, for example:

  • The instruction "addition with direct parameter" ( add immediate ) has been removed, because instead of this instruction, the command "Subtract direct" might as well ( subtract immediate ) with the complement to be used.
  • The resulting on The vacant place was for realizing a "addition with direct 16-bit parameters" ( add immediate word used).
  • A command such as "Comparison with the Carry flag " ( compare with carry ) was introduced to an efficient comparison of 16- and 32-bit values - as it is in high level languages of the day - allow.
  • Instead of two address registers , three address registers were provided.
  • An initially planned segmented memory layout was completely dispensed with because it is difficult to handle by compilers.


The AVR microcontrollers require supply voltages between 1.6 V and 5.5 V. Depending on the type, they can be operated with external crystals up to 32 MHz and offer the following peripherals, among others: ADC , timer , watchdog , UART , two wire interface (I2C) , SPI , CAN , USB , display interface, touch controller, analog comparators and external interrupts. The configuration of some peripherals and processor functions, such as the external clock generator, the bootloader, the watchdog timer or a read-out block for the program memory, is not carried out in the program code, but via separately set fuse bits.

Nomenclature of the model variants

All real AVR microcontrollers from Microchip (except AVR32) have the following nomenclature :


The naming always follows the same scheme.

Current module as an example: * ATmega48PA-AU *. The name consists of five parts:

  1. The series (here: "ATmega").
  2. A number, always a power of two (here: 4). This number indicates the size of the flash memory in Kibibytes (KiB).
  3. Up to three more digits (here: 8). You define the additional functions and the number of I / O ports.
  4. Up to two letters (here: PA), which stand for the revision and special energy-saving architectures.
  5. A hyphen and two more letters that indicate the design (here: AU).

model series

There are only three rows: the small ATtiny with a reduced range of functions and the large ATmega and AT90 models with special functions.

Memory size

While the size of the flash memory (program memory) is specified directly in the name, the size of RAM and EEPROM is only indirectly derived from this number, whereby typically the components with large flash also have more RAM and EEPROM than smaller ones. This assignment roughly applies:

Flash (KiB) EEPROM (B) RAM (B)
ATtiny ATmega ATtiny ATmega
2 128 - 128 -
4th diverse 256 diverse 512
8th diverse 512 512 1024
16 - 512 - 1024
32 1024 2048
64 2048 4096
128-256 4096 4 Ki – 16 Ki

Additional functions / size

The number (s) after the flash size indicate the features of the module. The following table applies to the ATmega series:

Digit description
- The building blocks of the first generation are not marked by a number. As a rule, they have a lower maximum clock rate (8/16 MHz instead of 10/20 MHz), a higher minimum voltage (2.7 instead of 1.8 volts), fewer interrupt sources and PWM channels.
0 Range from 32-256 KiB in a larger package with a higher number of I / O pins. A little older than the current series 4 and 8.
1 Identifies an improved version of the ATmega128 / 256, but older than the current 4 series.
4th Range from 16 to 128 KiB Flash, all pin compatible in 40–44-pin housing. Latest series, all in pico-power technology with many improved functions, such as external interrupts, timers, USART ...
5 Range from 16 to 64 KiB.
8th Range from 4 to 32 KiB, all pin compatible in 28–32 pin housing. Latest series, all in pico-power technology with many improved functions, such as external interrupts, timers, USART…. (also available in the ATtiny range)
9 Range from 16 to 64 KiB with integrated controller for LC displays, consequently in large housings (64- / 100-pin)

From this list, some building blocks stand out as outsiders:

  • ATmega8515 / ATmega8535 - are only intended to operate an SRAM .
  • ATmega640: In principle an ATmega64 with significantly more hardware resources (4 UARTs, 16 ADC channels ...) and twice as much EEPROM / SRAM.

Revision / architecture

The (optional) letters in front of the hyphen provide information about the power consumption and voltage range

Letter description
A. Second revision - mostly just a change in the internal structures without any impact on the user, sometimes with an internal temperature sensor
B. Third revision - some improvements: Improved AD converter (15 kSamples / s), integrated serial number (9 bytes) and USART wake-up in "power-down" state
L / V "Low-Voltage": components specially selected for lower clock rates (8 or 10 MHz) and lower input voltages (1.8 or 2.7 V)
P / PA "Pico-Power": Reduced power consumption, especially in deep sleep modes (<1 µA); Some modules (e.g. ATmega48) are available as P and PA
HV / HVA "High-Voltage": Special models with peripheral units for controlling battery chargers that can be operated with up to 18 V.
RF "Radiofrequency": Models with an integrated transceiver for the 2.4 GHz ISM band


The two letters after the hyphen provide information about the design. The number of pins of the respective housing type depends on the component.

1st letter description Type
A. TQFP housing SMD
C. BGA housing
J PLCC housing
S. SOIC Enclosures
M. (V) QFN / MLF housing
P DIP housing THT
2nd letter description
I. Contains lead - no longer available
U Lead free, RoHS compatible


The numbering of the ATtiny modules is much more confusing than in the ATmega series. As with ATmega, the first digit indicates the size of the flash memory. The above tables for series, design, revision and memory size also apply (exceptions: ATtiny5 with 0.5 KiB Flash and ATtiny4 and ATtiny9 with 0.5 or 1 KiB Flash). The additional functions and size do not appear from the designation.

AT90 series

Follow the same nomenclature as ATmega, only replacement of the series by AT90 plus special function (PWM, CAN, SC or USB).

Storage architecture

The storage management follows the guidelines of the Harvard architecture . So there are separate address spaces for the flash memory , the RAM and the EEPROM . In contrast to simpler microcontrollers, the AVRs have 32 registers with which operations can be carried out directly, but not all registers have the same scope of performance. The Tiny types in the very small SOT23-6 housing (ATtiny4, ATtiny5, ATtiny9 and ATtiny10) only have 16 registers.



AVR XMEGA are microcontrollers with extended peripherals and functions based on the 8-bit AVR architecture.

In detail, depending on the series (A1-3, B1-3, C1-3, D1-3), the extensions include:

  • multiple DMA channels
  • Hardware cryptography ( AES and DES )
  • Clock rates up to 32 MHz
  • Program memory of up to 384 KiB
  • The ADCs now have a resolution of 12 bits
  • DACs have been added
  • An external interrupt can be assigned to each I / O pin

Some interfaces have been improved and are now mostly available multiple times, for example SPI, TWI and USART. The interrupt system has been revised. A so-called event system allows incoming interrupts to be forwarded directly to peripheral units without requiring additional processor computing time ( hardware routing ).

According to Atmel, the components of the XMEGA series are compatible with the existing AVR components in terms of the instruction set. Within the XMEGA series itself, all of the respective housing shapes are pin, source text and binary code compatible, but the supply voltage has been reduced to 3.3 V (max. 3.6 V), so that an exchange in an existing design is only possible if if this voltage is also available here and the other components can also work with 3.3 V port voltage.


These are derivatives of the AVR32 architecture mentioned above. It is a 32-bit controller that only has the same name as the 8-bit architecture discussed in this article.

AVR-compatible microcontrollers and replicas

  • Integral or the Belmicrosystems Group from Belarus offers the Classic AVR replicas IN90S2313DW, IN90LS2323N, IN90S2323N, IN90S2333DW and IN90LS2333DW, which are advertised as pin-compatible with the corresponding AVR types from Atmel. Even parts of the English data sheet have been adopted unchanged.


There is also a large number of free development tools, such as B. the GNU tools ported for AVR cross compiling WinAVR or avr-gcc , AVR-LibC.

Finally - rather unusual for microcontrollers - there are the proprietary BASIC compilers BASCOM and LunaAVR .

General overview of AVR compilers and manufacturers (incomplete)
Compiler Manufacturer License platform particularities
avr-as GNU GPL Win32 , Linux , Mac OS free, open source
avr-gcc GNU GPL Win32 , Linux , Mac OS free, open source
AVR-Ada GNU GPL Win32 , Linux free, open source
Atmel Studio (formerly AVR Studio) Atmel proprietary Win32 free
Arduino platform Arduino GPL Win32 , Linux , Mac OS free, open source
GNAT Pro AdaCore GMGPL Win32 , Linux only with a professional support contract
ControllerLab cadManiac.org GPL Linux Development environment, free, open source
AVRco E-LAB Computers proprietary Win32 Demo version available, ATMega8 / 88 standard version available free of charge
Pascal-scm E-LAB Computers proprietary Win32 Demo version available, ATMega8 / 88 standard version available free of charge
BASCOM MCS Electronics proprietary Win32 Basic compiler. The free demo version compiles up to 4 KiB binary code.
LunaAVR rgf software proprietary Win32 , Linux , Mac OS object-based, modern Basic / Pascal-like dialect, free of charge
mBasic nettypes.de proprietary Win32 free for private use, spec. Hardware required
NanoVM Till Harbaum GPL Win32 , Linux free, open source
amforth Matthias Trute GPL Win32 , Linux free, open source
Python on chip Dean W. Hall et al. GPL Win32 , Linux , Mac OS free, open source
IAR Embedded Workbench for AVR IAR Systems proprietary Win32 MISRA support, high code quality, expensive (a price request results in 3000, - € purchase price), Kickoff version limited to 4K free of charge, direct cooperation with ATMEL
myAVR Workpad myAVR proprietary Win32 Demo version available
SiSy AVR Laser & Co Solutions proprietary Win32 Program flowchart , UML - Class Diagram State Machine
Algorithm Builder Gennady Gromov proprietary Win32 Demo version available, graphical?
AVRA Jon A. Haugum, Tobias Weber GPL Platform independent Free, open source, Atmel Studio compatible
CodeVisionAVR HP InfoTech proprietary Win32 Demo version available
MikroPascal for AVR Microelectronics proprietary Win32 2K demo version available
MikroC PRO for AVR Microelectronics proprietary Win32
MikroBasic PRO for AVR Microelectronics proprietary Win32
PasAVR Vogelaar Electronics proprietary Win32 Cross compiler for Object Pascal , is supplied with the manufacturer's DelphiStamp
Flowcode for AVR Matrix multimedia proprietary Win32 Graphic programming language based on flow charts. Free demo version with limited code scope.
ICCV8 ImageCraft proprietary Win32 Demo version available, Code :: Blocks IDE, Application Builder
Supported language (s)
Manufacturer Compiler Ada Assembler BASIC C. C ++ Pascal other
GNU avr-as No Yes No No No No
GNU avr-gcc No yes ( inline ) No Yes Yes No
GNU AVR-Ada Yes No No No No No
Atmel Atmel Studio No Yes No Yes Yes No
cadManiac.org ControllerLab No No Yes Yes Yes No
Conrad Electronic C-Control Pro No Yes Yes Yes No No
E-LAB Computers AVRco No No No No No Yes
AdaCore GNAT Pro Yes No No Yes Yes No
MCS Electronics BASCOM No yes ( inline ) yes (dialect) No No No
nettypes.de mBasic No No Yes No No No
rgf software LunaAVR No Yes Yes No No No Object-based dialect, semantics and syntax based on Xojo , Pascal , C ++
Till Harbaum NanoVM No No No No No No Java
Matthias Trute amforth No No No No No No Forth
Dean W. Hall et al. PyMite No No No No No No python
IAR Systems IAR Embedded Workbench for AVR No No No Yes Yes No 4K limited kick-off version free of charge, many ATMEL application notes for IAR available
myAVR myAVR Workpad No Yes No Yes Yes No
myAVR SiSy AVR No Yes No Yes Yes No Additional code generation from: program flow chart (ASM), structured diagram (C), UML class diagram (C ++), UML state diagram (C ++)
Gennady Gromov Algorithm Builder No Yes No No No No Code generation from flow representation
Jon A. Haugum, Tobias Weber AVRA No Yes No No No No extended macro language?
HP InfoTech CodeVisionAVR No No No Yes No No
Microelectronics MikroPascal for AVR No No No No No Yes
Microelectronics MikroBasic PRO for AVR No No Yes No No No
Microelectronics MikroC PRO for AVR No No No Yes No No
Vogelaar Electronics PasAVR No No No No No Yes Cross compiler for Delphi
Matrix multimedia Flowcode for AVR No No No No No No Flowcharts
ImageCraft ICCV8 No Yes No Yes No No

Further development tools

  • AVR IO Designer - a free IO register configuration tool for ATtiny, AT90 and ATmega, similar to the CodeWizard included in CodeVision.

Development boards

Development board STK500

In principle, only a few components are required to easily develop and program a circuit with an AVR. Nevertheless, beginners in particular appreciate so-called development or evaluation boards (development boards), which offer peripherals (LEDs, switches, etc.) in addition to the AVR . Atmel itself offers corresponding official boards (STK200, STK500, STK600) that can be used universally for several types. In addition, there are separate boards for special controllers, such as the “Butterfly” and the various “XPlained” boards. Various providers offer inexpensive alternatives.

In recent years, the open source Arduino platform based on the AVR has been particularly popular, as it enables beginners and non-specialists such as artists and designers to use microcontrollers without in-depth technical knowledge.

German-language literature

  • Ingo Klöckl: AVR® microcontroller. MegaAVR® - development, application and peripherals . 1st edition. de Gruyter-Verlag, 2015, ISBN 978-3-11-040768-6 (programming of the MegaAVR types in C and assembler, presentation of all assemblies, flags and functions).
  • Günter Schmitt: Microcomputer technology with controllers from the Atmel AVR-RISC family . 5., completely redesigned. and exp. Edition. Oldenbourg-Verlag, 2010, ISBN 978-3-486-58988-7 (introduction to AVR architecture (Tiny and MEGA), based on assembler and C).
  • Wolfgang Trampert: AVR-RISC microcontroller . Franzis-Verlag, 2000, ISBN 3-7723-5474-2 (hardware and assembler-oriented, classic AVRs only).
  • Roland Walter: AVR microcontroller textbook . 3. Edition. Denkholz-Verlag, 2009, ISBN 978-3-9811894-4-5 (systematic book, based on ATmega8 / BASCOM, suitable for teaching (here preview )).
  • Safinaz and Francesco Volpe: AVR microcontroller practice . 3. Edition. Elektor-Verlag, 2003, ISBN 3-89576-063-3 (mainly instruction set of the AVR assembler in German).
  • Claus Kühnel: Programming the AVR-RISC microcontroller with BASCOM-AVR . 3rd, arr. and exp. Edition. Script-Verlag Kühnel, 2010, ISBN 978-3-907857-14-4 (systematic book, focus on BASCOM, but also with assembler routines).
  • Peter Urbanek: Embedded Systems . HSU-Verlag, 2007, ISBN 978-3-9811230-1-2 (Introduction to the AVR architecture with examples in C based on the ATmega16. Connection of an external CAN controller with examples.).
  • Roman Mittermayr: AVR-RISC: Develop your own embedded software . Franzis-Verlag, 2008, ISBN 978-3-7723-4107-6 (introduction to assembler for ATmega / ATtiny based on various projects; most important basics of C programming).
  • Florian Schäffer: AVR - hardware and C programming in practice . Elektor-Verlag, 2008, ISBN 978-3-89576-200-0 .
  • Claus Kühnel: Programming the AVR RISC microcontroller with BASCOM-AVR . 3rd revised and expanded edition. Script Verlag Kühnel, 2010, ISBN 978-3-907857-14-4 .
  • Günter release: AVR microcontroller program in C . 1st edition. Franzis-Verlag, 2010, ISBN 978-3-645-65019-9 .

Web links

Commons : Atmel AVR  - collection of images, videos and audio files

Individual evidence

  1. The AVR Microcontroller and C Compiler Co-Design . (PDF) cheef.netronik.ru
  2. atmel.com (PDF)
  3. a b ATmega640 has twice the memory
  4. Rev.B atmel.com
  5. mikrocontroller.net
  6. atmel.com
  7. atmel.com
  8. AVR-LibC: Homepage