AVR quick start

From DP

Jump to: navigation , search

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.

Contents

Features

  • 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.

Programmers

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

Debuggers

  • 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.

Bootloaders

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.

Basic circuit

Basic AVR circuit

Power

  • 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

  • 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

Programming connections

Most AVRs use a 6 or 10 pin programming connection called ISP (in system programming).

AVR ISP Connectors (Top View)

ISP Connector pinout
Signal 6-Pin 10-Pin I/O Description
VTG 2 2 - Power is delivered from the target board (?)
GND 6 3,4,6,8,10 - Ground
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

Clock source

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.

Further information

The Atmel application note "AVR042: AVR Hardware Design Considerations" goes further in depth on the topics covered on this page.

Programming

Tutorials - Getting Started

Tutorials - Specific Topics

Interrupts

Using the on-chip eeprom

Development Environments

AVRs and USB

AVRs with hardware USB
USB on AVRs without hardware support

Peripherals

IO

  • General guide to PORT current limits

USB

  • Basic AVR USB circuit requirements
  • USB supply
  • Any components needed for the USB PHY