AVR quick start
The Atmel AVR family of microcontrollers (wikipedia) is very popular in many projects found on the web. The AVR is much younger than the PIC, but its usage has spread quickly. The toolset for programming AVRs is open source and available on Windows, Mac OS X and Linux. The open source Arduino (wikipedia) project which has made microcontrollers more accessible to a larger group of people uses an AVR ATmega as its core. After starting out with the Arduino platform, a logical next step is to work with bare AVRs. The focus on this page is for working with bare AVRs directly.
- Open source and multi-platform tools
- Many programming options that do not require a dedicated hardware programmer
Development and programming
IDE and compiler
One of the super nice things about the AVR are the totally open source tools.
- AVR GCC - GCC tool chain (compiler, assmebler, linker) targeted for AVR. AVR libc C library for AVR
- WinAVR and GCC (GPL)
- Atmel's AVR Studio 4 (Windows Only, registration required, uses avr-gcc)
- CrossPack similar to WinAVR but for Mac OS X.
- Eclipse AVR - An AVR development plugin for the Eclipse IDE, based on the Eclipse C Development Tools (CDT).
- Linux - Many Linux distributions include the AVR toolchain for 8 bit and 32 bit AVR development. There are quite a few tutorials for installing the AVR tool chain.
Typically AVR programming can be done with the normal circuit voltage 5 V or 3.3V, which allows many different low cost options for getting started with AVRs. The open source and multi-platform AVRDude (AVR Downloader Uploader) utility is commonly used for programming AVRs. AVRDude is included in some of the AVR IDEs such as WinAVR and Arduino. AVRDude supports using the Bus Pirate as an AVR programmer since release 5.8.
- Bus Pirate AVR Programming - The Bus Pirate can be used as an AVR programmer with AVRDude, eliminating the need for a separate AVR hardware programmer. Note: some older versions of the Bus Pirate firmware are incompatible with AVRDude.
- Atmel STK500 programmer. Many clones are available.
- (Bus Pirate as an STK500 clone ) - Using an alternate firmware on the Bus Pirate, it can emulate the STK500 programmer. Use this if you require compatibility with some AVR programming software other than AVRdude. Recent versions AVRDude can be use the Bus Pirate directly with the default Bus Pirate firmware. a
- AVR ISP (and kits)
- ArduinoISP The Arduino can be used as an AVR ISP programmer after loading the ArduinoISP sketch.
- FTDI Bit Banging - The popular FTDI USB to RS-232 chip can be used for bit-banging. See Hack-a-day Introduction to FTDI Bit-bang Mode. It's possible to use an FTDI converter with 5V or 3.3V outputs to program AVRs. This can be one of the slower ways to program AVRs however many people have FTDI converters lying around.
- Dangerous Prototypes has an FT232 programmer in development.
- FTDI USB serial TTL converters are available in many forms from FTDI, SeeedStudio, etc.
- It's possible to use the FTDI chip on some Arduino's such as the Duemillanove and clones.
- Mega-ISP Arduino shield
- MKII (full AVR debugger)
- AVR Dragon, low cost programmer and debugger.
High voltage programmers
AVRs also have an alternate 7-pin programming mode that requires a 13volt supply. This mode is usually only needed to enable/disable the RESET pin. Very few programmers support this mode.
AVRs do not ship with a bootloader, but there are many that you can program yourself. After the bootloader is installed, a programmer is no longer needed for simple firmware updates.
- Arduino Bootloader
- fast tiny & mega UART bootloader (registration required) (license?)
- kavr (GPL)
- LUFA (MIT Licensed) contains USB bootloaders for the following USB classes:
- Connect all the supply pins to power (Vcc) or ground (Vss). Don't forget the AVcc and AVss pins
- Put a 0.1uF decoupling capacitor on each positive supply pin, and put it as close to the chip on your PCB as possible
- Reset is the RESET pin on AVRs
- Connect a resistor from RESET to the supply voltage for normal operation. Any value between 1K and 10K ohms should work fine
Most AVRs use a 6 or 10 pin programming connection called ISP (in system programming).
|VTG||2||2||-||Power is delivered from the target board (?)|
|MOSI||4||1||Output||Commands and data from Programmer to target AVR|
|MISO||1||9||Input||Data from target AVR to Programmer|
|SCK||3||7||Output||Serial Clock, Controlled by Programmer|
|RESET||5||5||Output||Reset. Controlled by Programmer|
Most AVR's have an internal RC oscillator, clocked at 8Mhz, that can be used as the clock source. By default the Clock divider fuse (CKDIV8) is programmed, resulting in a 1Mhz clock.
- An external clock source, resonator, or crystal can be attached to the XTAL1 (input) and XTAL2 pins.
The Atmel application note "AVR042: AVR Hardware Design Considerations" goes further in depth on the topics covered on this page.
Tutorials - Getting Started
- Hack-a-Day AVR Programming tutorial, Part 2, Part 3, Part 4
- Evil Mad Scientist Laboratories Resources for Getting Started with AVRs
- Reading (and writing) the AVR flash with AVRDude - in other words how to backup as well as program an AVR.
- Adafruit AVR Tutorial, Currently a work-in-progress, with good system setup info.
- Sparkfun Beginning Embedded Electronics, a very thorough introduction to using microcontrollers that focuses on the ATmega168.
- AVR Freaks Tutorial Forum
Tutorials - Specific Topics
- Hack-a-Day: Beginners Concepts All About AVR Interrupts
- AVRFreaks: Newbie's Guide to AVR Interrupts
- Protostack: ProtoStack: External Interrupts on an ATmega168
- Protostack: Timer Interrupts on an ATmega168
Using the on-chip eeprom
- Protostack: Reading and Writing the AVR's eeprom Example counts how many times the chip has been powered up, and shows a test circuit with LCD connected.
AVRs and USB
AVRs with hardware USB
- Two ATmega32u4 Breakout boards: Adafruit ATmega32u4 Breakout board with comparison to PJRC Teensy Teensyduino
- LUFA Lightweight USB Framework for AVRs for USB based AVRS like ATmegaxxUx. See V-USB for USB bit banging on regular AVRs.
USB on AVRs without hardware support
- General guide to PORT current limits
- Basic AVR USB circuit requirements
- USB supply
- Any components needed for the USB PHY