December 2008


Not really a snow day but it was finally cold enough and the humidity was low enough in Spicewood, TX to make a little snow. We don’t have the snow makers like the ones on snowathome.com (Although I’m sure we will some day.) So we used a paint sprayer filled with water attached to an air compressor.

The temperature was about 29° and 51% humidity.

Since most of the projects I work on with Atmel are USB based the first thing I do is load AVRUSBBoot on a chip. Once the bootloader is on the chip you can re-program it by setting a jumper on your circuit and using the avrusbboot command line interface. (Example: avrusbboot ./filename.hex)

But how to get the bootloader on the chip in the first place? Easy. Buy a AVRISPMkII from an Atmel distributor. It comes with the necessary hardware and software to program chips. Then the question becomes: If I have a programmer why would I need a bootloader? I guess the answer is: convenience. Once a circuit is built with usb support, which is only 4 wires, it is easy enough to put a jumper on and use the bootloader. When I order a new batch of chips I could put them all on the programmer and load the bootloader all at once.

The downside to the usb bootloader is that it requires a 12Mhz crystal to be attached to the chip. (I primarily use Atmega8 chips.)

Although I have never used one there is a possibility of using a serial port or parallel port programmer built out of very few, cheap components.

There is a good overview of all the methods of programming an avr at ladyada.net.

One of the greatest beginning tutorials I have found for Atmel programming is the I Make Projects article called “A Quickstart Tutorial for ATMEL AVR Microcontrollers.” If you are just starting buy a couple Attiny45 chips and follow that.

Warning: To get a bootloader to work with usb you have to change fuse settings. It is easy to “brick” a chip if you give it the wrong fuse settings. Especially changing the clock and re-assigning the reset line. (Reset is needed to activate the In Circuit Programming.) Read, re-read, and triple read before reprogramming fuses. Look at RSTDISBL, SPIEN, and CKSEL.

When I prep an Atmega8 for use with the avrusbboot program I use Hight fuse @ C0 Low Fuse @ 9F and locks set to EF. As soon as you hit the button to program these fuses it will absoulutely need that 12Mhz crystal on pins 9 and 10 with the 27pf capacitors. Or you wont be able to talk to the chip again.

An online fuse calculator for avr chips.