# Fuse Bit settings in ATmega128 Micro controller

I am working with ATmega128 board. The datasheet states

ATmega128 is by default shipped in ATmega103 compatibility mode

In ATmega103 mode, the MCU both serial communications cannot be used and even some IO port operations are restricted. I want to disable ATmega103 mode, as I need both serial communications, external oscillator, and so on. To do this I need to program the fuse bits, and I need help in this issue. I am using AVR GCC compiler on Linux and AVRDUDE programmer to program the ATmega128.

I am not sure what your level of experience with ATmegas is (though reading the datasheet is a good sign!), so I'll start with something very basic, skip down if this is useless:

The term "programmer" in this context can refer to two different things:

• Software. In your case it is avrdude.
• Hardware. The piece of hardware that sits between the software programmer (avrdude, in this case) and your ATmega. Some examples of these are USBtinyISP, USBasp, Pocket AVR programmer, AVRisp, etc. To program the chip, including the fuses, you need both, and to say exactly what the avrdude command should be we need to know which hardware programmer you have.

If you are indeed new to AVR development, take a look at Lady Ada's AVR tutorial as Kurt E. Clothier points out.

The go-to site for me for fuse settings is the Engbedded Fuse Calculator. On that page, after you enter in your desired fuse settings, you will see the arguments you must provide to avrdude to burn the fuses correctly. For instance, to set default fuse settings, plus disable the ATmega103 compatibility mode use the following:

-U lfuse:w:0xc1:m -U hfuse:w:0x99:m -U efuse:w:0xff:m


You want to add the fuse commands to a regular avrdude command line that specifies the (hardware) programmer, MCU, etc. For me for instance, the base avrdude call (without an actual command) looks like this:

/usr/local/bin/avr/bin/avrdude.exe \
-p m328pu \
-C C:\\cygwin\\home\\angelatlarge\\arduino\\arduino-1.0\\hardware\\tools\\avr\\etc\\avrdude.conf \
-c usbtiny


(ignore the stupid Windows-style path to avrdude.conf in a Unix-type command line. On cygwin, only the Windows version of avrdude works, AFAIK. On most systems avrdude can find its conf file without the -C parameter anyway )

Where

• The first line is the path to avrdude
• The -p option specifies the MCU you are programming. For you it will be -p m128
• The -C parameter specifies the location of avrdude.conf file. Only necessary on stoopid systems like mine (cygwin running Windows version of avrdude).
• -c is the name of the (hardware) programmer you are using. Depending on the (hardware) programmer, you might also need to specify a serial port using the -P option. If I want to program an AVR chip over bluetooth, for instance, I use -P COM18.

To this we add the command to program the fuses, the result, for my setup, is as follows:

/usr/local/bin/avr/bin/avrdude.exe \
-p m128 \
C:\\cygwin\\home\\angelatlarge\\arduino\\arduino-1.0\\hardware\\tools\\avr\\etc\\avrdude.conf \
-c usbtiny \
-U lfuse:w:0xc1:m -U hfuse:w:0x99:m -U efuse:w:0xff:m

• That fuse calculator is a God send - saved me so much work in the past couple of years... On top of this, I would supplement this tutorial on AVR fuses. It isn't all inclusive, but should have everything you need in this instance (of course, substituting the windows CMD for Linux): ladyada.net/learn/avr/avrdude.html – Kurt E. Clothier Apr 22 '13 at 19:46
• Mixed forward / and back \ slashes? – jippie Apr 22 '13 at 19:47
• @jippie Thank you, now duly noted. This is intentional, and yes, stupid. Only necessary in cygwin, AFAIK. – angelatlarge Apr 22 '13 at 20:01