NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Setting Fuses

January 13, 2011
by n3ueaEMTP
n3ueaEMTP's Avatar

I've decided to venture into the world of ISP programmers without a bootloader. Trouble is, all of my programs use the fuse settings that my initial ATMega168 came pre-programmed with (from NerdKits). Here is my question: Will the following makefile work?

    GCCFLAGS=-g -Os -Wall -mmcu=atmega168
    LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
    AVRDUDEFLAGS=-c usbtiny -patmega168
    LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

    all:    phs-upload

        avrdude ${AVRDUDEFLAGS} -U lock:w:0x2f:m
        avrdude ${AVRDUDEFLAGS} -U hfuse:w:0xd5:m
        avrdude ${AVRDUDEFLAGS} -U lfuse:w:0xf7:m

    phs.hex:    phs.c
        make -C ../libnerdkits
        avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o phs.o phs.c ${LINKOBJECTS}
        avr-objcopy -j .text -O ihex phs.o phs.hex

    phs.ass:    phs.hex
        avr-objdump -S -d phs.o > phs.ass

    phs-upload: phs.hex
        avrdude ${AVRDUDEFLAGS} -U flash:w:phs.hex:a

How would I handle this?

all:    phs-upload

all: fuses install

Can they both be there, separated by some punctuation, or will just one suffice? Any help will be appreciated!! Thanks

Chris B n3ueaEMTP

January 14, 2011
by Rick_S
Rick_S's Avatar

Honestly, I program the fuses independantly. I don't place that in the makefile at all. The reason they are in the makefile for the foodloader is because that is expected to be run once when setting up a chip. After the fuse are set, there is no need.

I don't know if you've researched what those fuse settings do or not, but this is what they mean.


Self program mode cannot overwrite boot loader sction  No memory lock, and No 
restrictions for accessing the application section.

High Fuse Byte = D5

Reset pin enabled, debugWIRE disabled, SPI prgramming enabled, Watchdog timer not
always on, EEPROM is preserved thru chip erase, and Brown out detection settings.

Low Fuse Byte = F7

Clock is not divided by 8, Clock out is not sent out PB0, The remainder Designate a 
Crystal Oscillator of 4-20MHz Slowly rising power for 14 Clock cycles +65ms on 

The fuse settings as they are will work fine for an ISP loaded program. The only problem is you can overwrite the bootloader section via ISP because the bootloader is only protected in self program mode.


January 14, 2011
by Rick_S
Rick_S's Avatar

Just remember, that you will have to have a crystal in the circuit when programming the fuses like this other wise, the chip will not operate.

January 14, 2011
by n3ueaEMTP
n3ueaEMTP's Avatar

Rick, thanks for getting back to me. My end goal is to program the MCU once and not program it again so a bootloader is not necessary. So far, I've programmed the fuses and then put the program on the MCU. I'm just wondering if I can combine setting the fuses and the actual programming of the MCU. Thanks again


January 14, 2011
by Ralphxyz
Ralphxyz's Avatar

Why are you needing to (re)set the fuses?

Once I load the bootloader I then just flash any new program and never even think about the fuse settings, am I missing something?

I always try to practice "just because you can do something doesn't mean you should".


January 14, 2011
by n3ueaEMTP
n3ueaEMTP's Avatar

Ralph, excellent point.

My goal is to flash the MCU once and only once. My main project is a system for preforming tasks when firemen get emergency calls (Turning on lights, opening & closing garage doors, etc) so once it's flashed, it goes on the PCB, gets installed at a fire company and never gets thought about again. My prototype MCU will only get the fuses set once.

Post a Reply

Please log in to post a reply.

Did you know that you can control multiple LEDs from one microcontroller output? Learn more...