How to program an AVR



Introduction

This page explains how to program an AVR microcontroller with the 6 Pins ISP interface. (ISP means In System Programming).

ISP 6 Pins pinout: avr_isp-pinouts.html

goto top Up


Concepts

goto top Up


Tools

An adapter cable between a computer and the ISP connector is needed. Here are a few options:
Atmel AVR ISP

Atmel AVR ISP

Atmel ISP mkII

Atmel ISP mkII

goto top Up


Examples

Examples using UISP:
First of all, please note that in the following examples, /dev/avr is a symbolic link to the serial port device where the programmer is connected. (eg: /dev/ttyS0). Also, dont forget to change the -dpart argument if you are not using an AVR Atmega8.

Programming the fuses bytes on an atmega8:
# uisp -dprog=stk500 -dpart=atmega8 -dserial=/dev/avr --wr_fuse_h=0xc9 --wr_fuses_l=0x9f

Programming an hex file into an atmega8:
# uisp -dprog=stk500 -dpart=atmega8 -dserial=/dev/avr --erase --upload --verify if=n64_to_wii.hex
Note: --erase is for erasing the flash memory BEFORE programming the new file. --verify provides a way to read back the flash content and compare it with the original file to making sure no errors occured.

Examples using AVRDUDE and an USB ISP mkII:

Programming the fuses bytes on an Atmega8:
# avrdude -p m8 -P usb -c avrispmkII -Uhfuse:w:0xc9:m -Ulfuse:w:0x9f:m
Note: The -p option is used to specify which type of AVR you are programming. To display a list of supported device, try 'avrdude -p list -P usb -c avrispmkII' (since 'list' is not a valid type, avrdude lists supported types).

Programming an hex file into an atmega8:
# avrdude -p m8 -P usb -c avrispmkII -Uflash:w:n64_to_wii.hex -B 1.0
Note: The -B argument controls the ISP bit clock period (in microseconds). This frequency must not be higher than 1/4 of the MCU clock.

goto top Up


Tips and tricks

Here are a few details often unknown to beginners:

goto top Up


Trademarks used in this site are the property of their respectives owners.
Copyright © 2002-2014, Raphaël Assénat
Website coded withWebsite coded with vimLast update: December 12, 2014 (Friday)