USB Key AVR Programmer
2011/09/02 89 Comments
So, you saw some AVR microcontrollers and you decided they are cute (they really are!). If you choose to work in plain C what you need is just a toolchain (you probably have some package ready for your distribution), the avr-libc library, a programming software like avrdude and a hardware programmer!
While you can freely download all the software you need, including the source code, for the programming hardware you have to choose between buying a commercial programmer (either from Atmel or some third party) and building your own.
My version is a USB key-like design, using many SMD parts and a very small PCB. You can take it with you everywhere!
The microcontroller I used is an ATMega168-20AU, the SMD version with TQFP package. All passive components are in 0805 package, the clamping diodes are in SMA package, the USB connector is a PTH footprint (but an SMD one will fit fine) and the programming connector is side mounted.
There are currently two footprints for the programming connector of AVR controllers: the most common one, which is the one used in this design, is the one proposed by Atmel in the AVR910 application note.
The pinout is the following:
Please note that VCC pin can be used either to power the logic signal of the programmer at the correct target voltage (as it happens with the AVRISP mkII) or to power up the target hardware from the programmer itself.
This USBasp design, as the original one, provides a 2×1 jumper to send 5V power to the target, but there is an additional series resistor as a safety against short circuit.
Also, an additional 2×1 jumper is used for the initial programming and reprogramming of the device firmware. If you don’t have another programmer available and you need to program your first “smart” programmer, check out the parallel port BSD programmer (which was what I first used).
The third 2×1 jumper is used to manually select the low speed programming mode, which is what you need the first time you program an AVR device, as the default configuration for the microcontroller is to run at 1MHz, and the default programming speed of an USBasp is too high (the maximum programming speed is 1/4 of the system clock).
This jumper is not necessary anymore as the programming speed can be changed via software, using the -B flag of avrdude.
The one drawback of this design is that it only runs at 5V, so you need a couple of clamping zener diodes to limit the USB signal voltage. If you can’t find the SMD diodes, try using some white LEDs, they should have the right voltage drop and it’s nice to see the lights on the USB traffic!
Also, you should only use this to program 5V devices… 3.3V ones should work but you would push the target logic well over its limits. It may work for some time, but don’t blame me if this sets on fire your latest-greatest-funkyest project! Anyway, I do that quite often. Just don’t tell anyone… Ok?
A final note is that this design is not firmware compatible with the Thomas’s one, as the GPIO pin mapping was changed to simplify the layout.
You can download my version of hardware and firmware for this design from GitHub.
The schematics in PDF version can be downloaded from here.
The PCB is available on BatchPCB!