SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By Reggie
#90476
Hi all, this is my first post, I own a couple of arduinos (diecimila, Mega) and I wanted to start using other chips from the atmel range, so over the last couple of weeks I've been looking at different ways the chips can be programmed using an ISP (in system programming) cable.

There are of course all the usual AVR programmer cables that are around, unfortunately these cost money. It would also appear that due to freeday there are a few people around that would also like to program avr chips :)

This post will show you 3 ways to do it, all with kit you may own or are quite likely to purchase to support these chips, or will prove useful for other projects :) All of the methods are fairly simple to follow, 1 requires 4 solder points, the other 2 just require you to make the right connections.

The only caveat with hand programming using avrdude is that you *must* learn how to program the fuses and lockbits for your chips correctly before you actually program them, if you get it wrong you may render the chip useless unless you have a HV (high voltage) programmer. There are plenty of programs/calculators that will help you to do this (google avr fuse calculator). I will not be held responsible for any damage you may cause to anything using any of the methods listed below.


-----------------------------------------

Method 1.
This involves using an arduino, it will require you to solder 4x2.54mm header pins to a diecimila/duemilanove, I remembered this from hackaday originally.

http://www.geocities.jp/arduino_diecimi ... ld_en.html

Method one describes putting a bootloader onto an atmega 168 chip, but to get your bootloader of choice, or program any other atmega chip all you need to do is change the -p m168 switch, look through the avrdude.conf file for your chip, an atmega 328 is -p m328 an atmega16 is -p m16 (use this for all atmega 16s 16L, 16PU etc.)


Method 2. (my method of choice, the bob-718 is a superb board).

Using a sparkfun FT232RL 3.3v/5v breakout board (BOB-718) http://www.sparkfun.com/commerce/produc ... cts_id=718 you can use the avrdude.conf settings from method 1 and the commands for getting the getting a bootloader on.

The pin connections are:
Atmel chip------FTDI BOB
miso------------CTS
sck--------------DSR
mosi------------DCD
reset------------RI

Don't forget to ground the ftdi bob with the atmega circuits ground, you can program the chip initially using the 3.3v power, but its advisable to power the chip via some other means if you intend to repogram it in circuit as the ftdi bob is only capable of about 50 or so ma.

don't forget to change the -p switch to your chip!!

Method 3.

This method uses either the basic 3.3v or 5v version of the sparkfun ftdi breakoutboard:
http://www.sparkfun.com/commerce/produc ... ts_id=8772

http://www.sparkfun.com/commerce/produc ... ts_id=9115

All that is required is for you to set different pins as miso,mosi,sck and reset pins in avrdude.conf. While I was looking for the info for the pin mapping of the ftdi 232RL chips for avrdude I came across this webpage, that describes the pin mappings needed.

http://exmrclean.blogspot.com/2009/05/b ... b-ttl.html

Same rules apply for power as method 2, initial programming using 3.3/5v from the bob is ok, but in circuit you need to provide external power for the target chip and as always, gnd from the ftdi must be connected to the target crcuits gnd.

again, don't forget to use the correct -p switch for your chip.
-----------------------------------------


Thats pretty much it, obviously there is due praise for the writers of methods 1 Kimio Kosaka and 3 EXMRCLEAN and also Mr Suz for writing avrdude-serjtag, if either have a donation button and you feel it worthy then please go ahead and donate, method 2 is my own method, although i'm sure that its a documented on the net already somewhere :)

As I mentioned for any of the methods you may own the kit already or are quite likely to purchase the kit to support these chips.

Its quite likely that if you want to program atmega chips you either own an arduino already and are making the jump to other chips more suited to your projects needs, either that or you will need a serial connection between your target chip and a PC, using an FTDI bob you get the serial connection AND a programmer all in the same package.

If you are programming arduino compatible chips and using a bootloader it will even auto-reset the chip into programming mode for you.


Of course if you already have a serial connection to the PC via some other means then any of the AVR programmers will do the job but you really can't beat an FTDI bob from sparkfun, programmer and serial connection for <£10/$15 :)