IMG_3576The USBasp AVR programmer arrived today so I lost no time connecting it up to give it a try. This is a clever little beast that uses a software USB stack on a pre-programmed ATMEGA8 processor. It works directly with AVRdude to program your target processor with the minimum of fuss.

My example came from an eBay seller in Hong Kong and arrived complete with a suitable USB cable and 10 pin ribbon cable programming connector. I have plenty of cables but it was nice to see them included so that I could get straight on with the testing. How many times have you ordered stuff only to find the necessary cables are nowhere to be found?There you will find a schematic and source code to build your own. I had mine ready-made because the price was well worth paying to save an evening messing about and, in any case, I didn’t have a programmer to allow me to program the programmer. Now I do so I will probably build a couple of spares. For larger projects, it may even be worth building one of these into the project to allow easy programming and upgrading.To use the USBasp programmer with AVRdude, you will need to make sure the correct settings are used. I use a Makefile and the programmer settings look like this:

DEVICE     = atmega16
CLOCK      = 4000000
PROGRAMMER = -c USBasp

AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)

Note that there is no need to specify a port. The USBasp identifies itself as a named device when it is connected to the Mac. Using AVRdude in a Makefile means that you will also probably want to use it to set the fuses on your target device. This is a fiddly business not helped by the way Atmel use inverted logic.As an alternative, you could use AVRFuses.:

avrfuses

avrfuses2

This is a GUI interface to AVRdude and is able to show you the fuses specific to your selected processor – a great convenience. You still need to know what the damned things do though.If you use the Makefile generated by AVRMacPack, writing a hex file to the processor is a simple process. Either use AVRfuses to select a .HEX file and send it or use a command line:

make flash

The USBasp has a couple of jumper options (switches on mine). One of these allows the target to be powered from the USB bus. I tried that and had a fair bit of trouble. this should not have been awkward but is worth bearing in mind if you get problems. Powering the target independently eliminated those errors.Since the board is bare underneath and has no mounting holes, I chose to attach it to a small piece of thin plywood by means of a short length of heatshrink tubing. that should make it much less vulnerable to short in the mess that passes for a work environment on my desk:

IMG_3578

Find out more about the USBasp programmer here:
http://www.fischl.de/usbasp/
You can get a copy of AVRfuses here:
http://www.vonnieda.org/software/avrfuses
Find out more about setting AVR fuses here:
http://electrons.psychogenic.com/modules/arms/art/14/AVRFusesHOWTOGuide.php

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.