Reset Search
 

 

Article

How to program an AVR Microcontroller?

« Go Back

Information

 
Question

How can I program the flash, EEPROM, Lock bits or fuse bits of an AVR Microcontroller?

Answer

To program an AVR microcontroller you will need an AVR programming tool. Examples of AVR programmers made by Atmel are STK500, STK600, AVR Dragon, AVRISP mkII, JTAGICE mkII, JTAGICE3 and Atmel-ICE.

On the Atmel AVR web-page -  www.atmel.com/avr, select Tools and you will find a description of these AVR programming and debugging tools.

AVR MCUs can be programmed either through the Device Programming dialog in Atmel Studio or in command-line through the atprogram utility. Atmel Studio is free of cost. To learn more about Atmel Studio and to download it, please visit Atmel Studio webpage

Atmel Studio User Guide can be accessed through Help menu-> Help or through the online User Guide where the users can learn more about how to use the Atmel tools. In the User Guide you can read more about how to program your AVR using a specific Atmel Tool.

There exist different programming interfaces to program the AVR Microcontroller. The programming interfaces are device dependent. The datasheet of the devices have to be referred to find the programming interfaces supported by them.
Atmel Studio automatically filters the supported programming interfaces based on the device and the tool connected.

To know how to connect a programming tool to a device, please refer the User Guide. The documentation for the programming and debugging tools will be listed under Programmers and Debuggers section. Select your programming tool and go to Connecting the tools section to find your required connections for a programming interface.

For example, to connect a device using PDI interface with JTAGICE3, the following documentation will help you: http://www.atmel.com/webdoc/jtagice3/jtagice3.connecting_pdi.html

For example, to program the flash memory of an AVR MCU,

  1. Connect the AVR MCU to a programming tool.

  2. Open Atmel Studio and navigate to Tools->Device Programming dialog box.

  3. Select the programming tool, device and the programming interface.

  4. Read the Device ID to verify the connections between the tool and the device.

  5. Select the binary to be programmed (hex/elf/bin format) and the options (Erase/Verify).

  6. Select Program command to program the device.

The following are the programming interfaces used by AVR MCUs.

In-System Programming (ISP)

In-System Programming uses the AVR internal SPI (Serial Peripheral Interface) to download binary into the flash and EEPROM memory of the AVR. ISP programming requires VCC, GND, RESET and 3 signal lines for programming. No high voltage signals are required. The ISP programmer can program the internal flash, EEPROM, fuses and lock-bits.
The AVR MCU can be programmed at the normal operating voltage, normally 2.7V-6.0V. Please note that the ISP frequency (SCK) must be less than 1/4 of the target clock. The ISP frequency is set in the Device Programming dialog in Atmel Studio.
Atmel tools that support ISP programming are STK600, STK500, AVRISP mkII, and JTAGICE mkII, AVR Dragon, JTAGICE3 and Atmel-ICE.
If programming an AVR using ISP programming on a customer target board, please make sure that your ISP hardware design is compliant with the 'Connecting ISP lines' chapter in application note AVR042: AVR Hardware Design Considerations.

High Voltage Programming:

For High-Voltage programming a 12V programming voltage is applied to the RESET pin of the AVR device. All AVR devices can be programmed with High-Voltage programming, and the target device can be programmed while it is mounted in its socket.
Two different methods are used for High-Voltage programming: 8-pin parts use a serial programming interface, while other parts use a parallel programming interface.
The Atmel tools that supports high voltage programming is STK600, STK500 and the low-cost AVR Dragon.

JTAG programming:

AVR's that has the JTAG interface (Devices with 40 pins or more) can also be programmed using JTAG programming. The AVR Tools that supports JTAG programming is STK600, JTAGICE mkII, AVR Dragon, JTAGICE3 and Atmel-ICE.

PDI programming:

PDI is the new two-wire proprietary debug interface for ATxmega devices. It can download code into the flash application and boot memories, EEPROM memory, fuses, lock-bits and signature information. A minimum of four wires is needed to connect the AVR debugging Tool to the target board using the PDI interface. These signals are Vcc, GND, DATA and CLK. The CLK line is driven by the debugging tool and the DATA line carries half-duplex communications between the debugging tool and the target.
For more information on how to use this programming modes with your AVR programmer, please see the AVR Tools User Guide.

 

The AVR Third Party support web-page lists several third party programming and software tools  for AVR microcontrollers.
Attachment(s) 

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255