ATMega32 and the dreaded FUSE BITS

The AT90S8535 is now a bit old and practically obsolete. However, do not despair, a very similar microprocessor is available from Atmel. Not only is it "pin compatible" with the 8535, it has more program space and a small number of great new features.

I now recommend to my students the ATMega32. It is available in several speed grades. If you can get ATMega32-16PI, it can run at up to 16MHz. If you can only get the -8PI, in principle it can only go to 8MHz, but that's still very fast and very adequate for anyone starting out.

Watch out for the Fuse Bits

The venerable 8535 would run properly as soon as you wired it up. But the ATMega32 has something called "fuse bits" which are very low-level settings. If they are not set up correctly, the micro won't run properly. Fortunately this is something you only need to do ONCE for each ATMega32 that you buy. It will remember the settings forever.

To program the fuse bits correctly, open ICCAVR and select "Tools/In System Programmer" from the menu.

In the top right corner of the dialog box there are some buttons for reading and writing the fuse bits.

Connect your programming cable to the AVR as usual.

Enter 0xC9EF into the Fuse Bits text field. That is a two byte hex number. The first two letters are "zero" and "x".

Press the "W" button to write the fuse bits to the AVR.

Clear the Fuse Bits text field.

Press the "R" button to read the fuse bits back from the AVR. Confirm that you have 0xC9EF. If so, you are done.

What do the fuse bits mean? Well, it is complicated. You can read about them in the data sheet if you are interested. There are fuses for all sorts of different low-level functions of the chip, such as selection of the main clock signal, activation of the In System Programming feature, and the JTAG feature. I selected 0xC9EF as a typical set of fuses to make the ATMega32 as much like the AT90S8535 as possible so that the course material here will all still work as expected. The most important setting in my suggested fuse bits is to select an external crystal oscillator. The default is the internal RC oscillator which is SLOW. If you don't set the external-crystal option your micro will sort of run but at about one-twentieth the expected speed.

ATMega8535 fuses

The ATMega8535 is also very similar to the good old AT90S8535. However it does also have fuse bits. The above procedure should work fine but I recommend setting the fuses to 0xD9E1