AVR Programming & Programmers

From wiki.countercaster.com

Revision as of 01:08, 21 October 2009 by LucAdmin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

USBtinyISP

I have just built the excellent USBtinyISP AVR programmer. I ordered the kit from Adafruit Insustries. The kit and the instructions were excellent.

I also built a target board following these instructions.

The result, after a couple of hours of soldering, is a handy AVR programmer with a USB interface (which is just the ticket given that less and less laptops have serial and parallel ports).

After plugging the USBtinyISP into a spare USB port on a system running Windows XP, I was prompted for a driver. I used the v1.12. This worked fine with AVRDude 5.5 as bundled in WinAVR-20080512.

Testing it out

To check that everything was working, I plugged an ATtiny2313 into the target board and ran the following command:

avrdude -c usbtiny -p attiny2313

The following output was generated:

avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e910a
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

Looks pretty good to me!

Programming an AVR

A really nice tutorial in using AVRDude is available here. The offical AVRDude doco is available here.

Everything that follows is my cheat sheet for programming the ATtiny2313.

Programming Program Flash Memory

avrdude -c usbtiny -p attiny2313 -U flash:w:<program.hex>

Programming EEPROM Memory

avrdude -c usbtiny -p attiny2313 -U eeprom:w:<eeprom.eep>

Programming the Fuses

  • To program the fuses, use:
avrdude -c usbtiny -p attiny2313 -U lfuse:w:<0xHH>:m 
avrdude -c usbtiny -p attiny2313 -U hfuse:w:<0xHH>:m 
avrdude -c usbtiny -p attiny2313 -U efuse:w:<0xHH>:m 

Where HH is the desired fuse value, in hex.

  • Fuses can also be programmed from a file:
avrdude -c usbtiny -p attiny2313 -U lfuse:w:<low-fuse.hex> 
avrdude -c usbtiny -p attiny2313 -U hfuse:w:<high-fuse.hex> 
avrdude -c usbtiny -p attiny2313 -U efuse:w:<extended-fuse.hex> 
  • To read back the fuses, use:
avrdude -c usbtiny -p attiny2313 -U lfuse:r:<low-fuse.txt>:b 
avrdude -c usbtiny -p attiny2313 -U hfuse:r:<high-fuse.txt>:b 
avrdude -c usbtiny -p attiny2313 -U efuse:r:<extended-fuse.txt>:b

In each case, the fuse is written to the specified file as a binary number, i.e. 0bABCDEFGH.

Personal tools