Skip to content


Arduino AVR In System Programmer (ISP)

3-SPIRandall converted an Arduino into AVR chip programming hardware for use with AVRDude. The project programs AVR tiny13 and other tiny AVR chips using an Arduino. He provides code and instructions to implement the Atmel AVR910 In System Programming protocol.

This article was submitted by Randall Bohn as part of the “Hobby parts for articles” program. Randall received the Arduino Bare Bones Board kit for this great project.

I ported the Atmel AVR910 In System Programmer protocol to the Arduino. Now I can write programs to my ATtiny2313 and tiny13 chips. The Arduino sketch is available for download here. It works with the AVRDude programming software. This article will show how to use the Arduino to upload a program to the tiny13. The first step is to download the zip, extract the .pde file, then load it into the Arduino IDE, and write it to the Arduino. Next we can hook up the tiny13 chip.

The original AVR910 programmer didn’t support the tiny13 chip. I added tiny13 support to the Arduino version and assigned it part ID 1. I had to modify the avrdude.conf file also. I just added the following line

avr910_devcode=0x01

to the tiny13 section right after the stk500_devcode line.

1-powerI put the tiny13 chip on a solderless breadboard, and connected power to it from the Arduino. I also put a bypass capacitor from lead 8 to lead 4 on the tiny13. This helps smooth out the power to the chip.

I added LED support when I ported the avr910. The LED turns on when the system is in Programming mode. Add the LED to the breadboard. Connect it to the ground line with a 1Kohm resistor and to the Arduino pin 9. Mind the polarity of the LED. The reset line should also be connected, from pin 10 on the Arduino to pin 1 on the tiny13.2-reset-LED

Next connect the SPI interface. The Arduino’s Mega8 has hardware support for SPI. The SPI lines need to be connected to the tiny13 as follows:

Arduino ATtiny13
Pin 13 (SCK) Pin 7
Pin 12 (MISO) Pin 6
Pin 11 (MOSI) Pin 5

SPI-Cable

I use this cable to connect the SPI lines to the breadboard. The cable has to be twisted once to match up properly when the Arduino is next to the breadboard as in the photos above.

With everything connected you can power up the Arduino and start using AVRDUDE. First you need to know which port the Arduino is using. My USB Arduino shows up on port com4: so I’ll use that in the examples. We need to tell AVRDUDE which port to use, which part we are using, and which ISP programmer we are using. If you run following command line it should connect to the tiny13 and read the device signature (0x1e9007).

> avrdude -P com4 -p t13 -c avr910

AVRDUDE will also complain that it cannot read lfuse properly. Add the -u switch to get past this limitation.

> avrdude -P com4 -p t13 -c avr910 -u

With that working we can go into terminal mode with AVRDUDE and check the tiny13.

> avrdude -P com4 -p t13 -c avr910 -u -t

Enter ‘sig’ to view the device signature again:

avrdude> sig
Reading | ################################## | 100% 0.02s
Device signature = 0x1e9007

Enter ‘read flash 0 16′ to read the first 16 bytes of the flash memory. If the chip hasn’t been programmed it should be all 0xFF. You can also use hex numbers as follows: ‘read eeprom 0×10 0×10′.

With AVRDUDE in terminal mode we can write to the eeprom but not the flash on the tiny13. To store the string ‘BEEP’ into the eeprom you could enter the following:

avrdude> write eeprom 0 66 69 69 80 0
avrdude> read eeprom 0 8

If that worked you just wrote to the eeprom and read the contents back. Enter ‘quit’ when you are done with terminal mode.

AVRDUDE won’t write to the tiny13 flash in terminal mode because the flash is programmed in page mode. You have to write the flash from the command line. The -U switch is used to read and write memories from the command line. You can use more than one -U command at a time. Another thing to be aware of is that AVRDUDE will erase the chip before writing flash memory. Anything in EEPROM will have to be reloaded if you write to flash.

Start with the base command:

> avrdude -P com4 -p t13 -c avr910 -u

The add the -U command at the end. To write file ‘target.hex’ to the tiny13 use the following:

-U target.hex

This is the simplified syntax. You can use it when you want to write a hex file to the chip flash. The full syntax to write is:

-U flash:w:target.hex:i
(write target.hex to flash, target.hex is Intel S-Record format.) AVRDUDE can figure out the format of the file, so you can actually leave the :i off.

To write the EEPROM use:

-u eeprom:w:target.eep

You can also read out the chip contents and verify against a file on your disk.

SPI-mega8

The basic development workflow I use is to build the software in AVRStudio 4, then use AVRDUDE to write to the target chip. I’ve used it to program the tiny13, tiny15, tiny2313, and the mega8.

#####

Randall Bohn lives in Orem, Utah with his wife and three kids. He first learned assembly on the Timex/Sinclair 1000 . Since he couldn’t afford an assembler he would write the programs on paper, look up the opcodes in a table, and poke the resulting numbers into a BASIC string. He much prefers his AVR toolset.

Posted in Arduino, Development Tools, Microcontroller, Projects, Workshop Tools.


13 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. xSmurf says

    Neat :D Now we need one for JTAG hehe :)

  2. xSmurf says

    So I finally tried this (my USBTiny ISP died and I wanted to burn the program to a new t2313). Sadly I get this when I try to read the device code:

    avrdude: avr910_recv(): programmer is not responding

    Any idea?

  3. xSmurf says

    Addendum: I noticed using the debug output that the SPCR register seems to be wrong.

    AVR910
    1 commands received:
    $~~~~~~~~~~~~~~~
    Device is 1, DDRB is 22
    SPCR is 00
    FFFFFFFF 0

  4. xSmurf says

    So I rewrote the SPI init routine to
    SPCR = (1

  5. xSmurf says

    So I tried it out and I can say writing to flash works perfectly. Sadly, it doesn’t seem to be the case for writing fuses. Is there something I’m missing?

  6. rsbohn says

    You would have to use a ‘universal command’ to program the fuses. I haven’t done any fuses yet. AVR910 supports writing lock bits but that isn’t implemented in this Arduino code. I didn’t get your changes to the SPI init code, could you repost it?

  7. AParker says

    I am very interested in extending this to support fuse burning, do you have any suggestions?

  8. rsbohn says

    I’m looking at using the AVRISP protocol instead of AVR910. avrdude supports it better, and it will support burning the fuses. I’ll post here when it’s ready for initial release.

  9. RSBohn says

    Now available from the mega-isp project on google code
    http://code.google.com/p/mega-isp/
    http://www.xmission.com/~rsbohn/Arduino/avrisp_ard.00.zip

  10. AParker says

    Great work!

  11. Daniel says

    Hi,

    this works only on ATtiny13? i have an arduino usb (diecimila) and i want to program an ATmega32

    i think this is great project! congrats

  12. Tim says

    when i run avrdude -P com4 -p t13 -c avr910 i get a syntax error for the attiny13 after i added the line to make it supported

  13. Dok says

    I get an error when i run avrdude avrdude: error: selected device is not supported by programmer: t13

    I added the line of code like you said.