Making a USB based AVR Programmer

Monday, March 29, 2010 25 comments
Around time when I was beginning to learn about microcontrollers I had exchanged my laptop with a senior at college for his desktop - that's because the only way I knew how to program an ATMEGA chip was through either a serial port or a parallel port. USB programmers were not available widely and were generally thought to be expensive. The programming setup using a parallel port was very simple. I followed the DAPA programmer for my needs for some time. Here is a pic of the setup - ATMEGA8 chip on breadboard (pinouts matched against the one shown in above link), a parallel port DB25 connector and a USB cable that just to get 5V and GND quick and dirtly without any batteries and voltage regulators:


Over the time I learned about an inexpensive way of making a USB based AVR programmer called USBasp. It's faster, cheaper and has the convenience of letting you program AVRs from laptops. Here is a pic of the first USBasp programmer that I built, and promptly got my laptop back (in the link you can see more designs):


Plugging it into the laptop and seeing it get recognized was pure fun! Having it work right also meant that you could get it to a competition venue easily, in case you had to program the microcontroller again. Without this the only other way was to bring along a desktop which was just impractical. I can recall once at the IIT Techfest I had found a team bring a really old laptop which did have a parallel port and those folks were programming their chips on the spot and it just didn't feel fair for the rest of us... heh heh! I used this one for a long time, even took it to workshops at college and many came from time to time to get their microcontrollers programmed. Right now the one in the pic is with a friend who is using it for the project work at college. And here is another one that I built yesterday:


Looks neat, doesn't it! But making it wasn't hassle free this time. I started with programming an ATMEGA8 needed for the USBasp with DAPA programmer like the one in the first pic (except for I was not using an external crystal). Having written the USBasp firmware on the chip, I proceeded to program fuses (they need to be done for using the 12 MHz external crystal). One fuse byte got written and then the chip lost sync with the programmer. My programming softwares - both avrdude and uisp complained that they cannot read the chip. Such bad fuse scenarios are common and the one sweet way to recover the chip is to attach a crystal of right value to the dead chip and retry with the programmer. Alas, I did not have any ~20/22/27 pF caps in my stock to use with the crystal. I had to go to the local (which in my case is nowhere nearby) parts shop and I got the wretched caps that cost only two teaspoons of sugar! But then things flowed smoothly, after the dead chip received the much needed CPR and I got that neat looking DIY USB programmer for myself again.