How to re-set fuses to 8Mhz internal without an external oscillator

I found myself trying to bootload with 8mhz internal oscillator an Atmega328P-PU that came set to use a 16Mhz external oscillator; after much frustration, I learned you have to reset the fuses to bootload the Atmegas on the internal oscillator at 8Mhz. Then, after further frustration, I learned the fuses cannot be changed without an external oscillator if they are set to expect one...a nice catch22, and the local Radioshack did not have oscillators :0 . After much googling and reading, I found the necessary information to do this spread over multiple sites so I am adding it all here to help my fellow newbs.

What you MUST have: Arduino UNO board, jumper cables, a breadboard and, of course, the micro controller you are trying to reset.
Follow these steps:

  1. Wire arduino for bootloading:
    Arduino board - MC
    D13 - SCK
    D12 - MISO
    D11 - MOSI
    D10 - RST (1)
    D9 - XTAL1 (9)
    5v - AVCC (20) and vCC (7)
    GND - both GND (8 and 22)

  2. Load Atmega_Board_Programer (http://gammon.com.au/Arduino/Atmega_Board_Detector.zip) to the arduino board with the arduino programming environment set to (Tools) Board>UNO and Programmer> Arduino as ISP.
    Open the Serial Monitor, select Lilypad (8Mhz) and program it.

  3. From Examples load ArduinoISP.

  4. Download http://arduino.cc/en/uploads/Tutorial/Breadboard.zip to your Documents\Arduino\hardware\breadboard folder (create one if it does not exist already). Then restart the arduino programming environment and change the Tools> Board to "Atmega328 on a breadboard (8Mhz internal clock") which should now show at the bottom of the list.
    Then in Tools, select Burn Bootloader.

  5. Wire arduino for programming:
    Arduino board - MC
    RST - RST (1)
    RX - RX (2)
    TX - TX (3)
    5v - AVCC (20) and vCC (7)
    GND - both GND (8 and 22)
    *Remove microcontroler from arduino board

  6. Upload your sketch and enjoy.

Or you could just buy a 16 mHz crystal for ten cents and then reset the fuses the normal and easy way..

They also have 8 mHz crystals (cheaper - only eight cents each, lol.)

[edit] forgot to mention shipping is a buck plus small change here in the US, even for fairly large amounts of light weight stuff like most electronic components.

You don't need to add a crystal or resonator to reset the fuses, as long as you have an external clock source. Some ISP sketches similar to Arduino as ISP can provide an output PWM clock source to feed to the target m328P mcu that is expecting a crystal or resonator.

See Gammon's notes about "alternate clock sources" at, Gammon Forum : Electronics : Microprocessors : How to make an Arduino-compatible minimal board
And then the "Programming the Bootloader" section right below that. His programmer sketch will output an 8MHz clock source on the programmer D9 pin that you can connect to the target m328P XTAL1 pin. Use the Lilypad 8MHz selection. This should get you started to change the fuses to internal. From there you can then reprogram it via standard IDE burn bootloader process.

@hiduino - Oh, yeah, I almost forgot about that. I used that sketch a long time ago before I discovered I could buy a whole bagful of crystals for a couple bucks.

Yes, buying crystals may be easy for some or many, but there are also a lot of people from around the world that don't have easy access to crystals or various components. Or let alone afford one.

These alternate programming methods are still very good to for many to get by without additional resources.

pegwatcher:
Or you could just buy a 16 mHz crystal for ten cents and then reset the fuses the normal and easy way.

You mean 16 MHz. :astonished: Mind you, it isn't quite as simple as that - you also need a couple of capacitors, though you could fudge them by wrapping insulated wire (such as telephone cable off-cuts or transformer wire) around the wires. If you had one of those nifty LCR meter modules, you could even get the right capacitance!

pegwatcher:
Or you could just buy a 16 mHz crystal for ten cents and then reset the fuses the normal and easy way…

Or you can not use a crystal at all. Almost any square wave source will do. Some versions of the ISP sketch even output one on a spare pin for you to use.

fungus:
Or you can not use a crystal at all. Almost any square wave source will do. Some versions of the ISP sketch even output one on a spare pin for you to use.

Which is why Nick Gammon's tutorial quoted earlier, is the preferred reference.

You mean 16 MHz. smiley-eek Mind you, it isn't quite as simple as that - you also need a couple of capacitors, though you could fudge them by wrapping insulated wire (such as telephone cable off-cuts or transformer wire) around the wires. If you had one of those nifty LCR meter modules, you could even get the right capacitance!

You might not even need the capacitors. Out of curiosity, I tried several of my crystals without any capacitors and they all ran. And they were situated close to the 328 oscillator pins so stray capacitance was minimal. Don't know if the frequency was affected but it wouldn't matter in the OP's case. And, if you're buying crystals, you might as well buy the capacitors at the same time from the same source, at a penny or two each where I get my stuff.

Sorry for resurrecting this old thread.

I followed this guide and all seems fine.
Blink sketch rns just fine without the external oscillator at 5V Vcc.
However if I use 3.3V Vcc the chip seems to not execute anything.

Any ideas why?

I'm kind of new to this, and wold really love to get my 3.3V sensors and stuff working "natively" on my next project...

BOD set to 4.3V.

Thank you for your reply, Coding Badly.

I wish I knew what you are talking about :o
Is that a fuse thing? How do I get over it? I'm using Arduino as the ISP, since I have no programmer...

Well, what I'm after is this:

Using Arduino UNO as ISP to burn the different sketches and then operating the chip at 3.3V in order to avoid level shift-ers.
I do not mind if I need to use an external or internal clock source. My main issue is the voltage.

The chip I'm experimenting with had a Arduino bootloader burned in it. Do not know if it makes any difference.

nikosk:
Is that a fuse thing?

Yes.

BOD → Brown Out Detector
4.3 V → 4.3 volts (I should have included a space; apologies to Nick.)

The Brown Out Detector holds the processor in reset when the voltage is below the threshold. The threshold is set using fuses. Typically, the BOD threshold is set to 4.3 volts.

How do I get over it?

You will have to change the fuses.

I’m using Arduino as the ISP, since I have no programmer…

No problem.

The chip I’m experimenting with had a Arduino bootloader burned in it. Do not know if it makes any difference.

No.

Did you prepare the target by following the instructions in the original post?

Yeap, I followed exactly the steps mentioned.

Wired up everything like mentioned:

Arduino board - MC
D13 - SCK
D12 - MISO
D11 - MOSI
D10 - RST (1)
D9 - XTAL1 (9)
5v - AVCC (20) and vCC (7)
GND - both GND (8 and 22)

  • Then downloaded the ATMega Board Programmer from Nick Gammon Github (as the one on the link did not compile for me) and burned the Lilipad bootloader.
  • I then used an older IDE version (1.0.5, as I'm still trying to understand what needs to be done in order to see custom boards on the 1.6.x IDE versions), loaded the breadboard.zip and burned the bootloader (not sure why we burn the bootloader twice, one using Nicks' sketch and one using the IDE, but since it worked I rest my case).
  • Re-wired again, removed the ATMega from the UNO and burned the blink sketch.

So I guess I will either need a modified bootloader (its the bootloader that also sets the fuses, right?) or to use avrdude to modify them ???

No. No.

You will need to change the entry in the boards.txt file. This is the original version I just downloaded…

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

You will be changing these entries…

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05

I use the “fuse calculator” here… http://www.engbedded.com/fusecalc/

The fuses above set the BOD to 2.7 V so that is probably not what is causing the problem. In case you want to try a different BOD setting I suggest disabling it until you determine what is wrong. After changing extended_fuses to the value below then executing Tools / Burn Bootloader the BOD will be disabled.

atmega328bb.bootloader.extended_fuses=0x07

Right, will try that when I’m back at home this afternoon.
Thank you Sir.

Got some time to experiment with it a bit.

I used Nicks' Board detector to see what Fuses are written to the chip:

Atmega chip detector.
Written by Nick Gammon.
Version 1.17
Compiled on Jul  9 2015 at 01:30:19 with Arduino IDE 105.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x0F 
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = 0xE2 
HFuse = 0xDA 
EFuse = 0xFF 
Lock byte = 0xCF 
Clock calibration = 0xC3 
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 2048 bytes starting at 7800

Extended fuse seems a bit off... So I restarted the whole procedure.

First burned the Lilo bootloader using Nicks' Board programmer:

Atmega chip programmer.
Written by Nick Gammon.
Version 1.35
Compiled on Jul  9 2015 at 01:32:15 with Arduino IDE 105.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x0F 
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = 0xE2 
HFuse = 0xDA 
EFuse = 0xFF 
Lock byte = 0xCF 
Clock calibration = 0xC3 
Type 'L' to use Lilypad (8 MHz) loader, or 'U' for Uno (16 MHz) loader ...
Using Lilypad 8 MHz loader.
Bootloader address = 0x7800
Bootloader length = 1932 bytes.
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x7800
Committing page starting at 0x7880
Committing page starting at 0x7900
Committing page starting at 0x7980
Committing page starting at 0x7A00
Committing page starting at 0x7A80
Committing page starting at 0x7B00
Committing page starting at 0x7B80
Committing page starting at 0x7C00
Committing page starting at 0x7C80
Committing page starting at 0x7D00
Committing page starting at 0x7D80
Committing page starting at 0x7E00
Committing page starting at 0x7E80
Committing page starting at 0x7F00
Committing page starting at 0x7F80
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xE2 
HFuse = 0xDA 
EFuse = 0xFD 
Lock byte = 0xEF 
Clock calibration = 0xC3 
Done.
Programming mode off.
Type 'C' when ready to continue with another chip ...
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x0F 
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = 0xE2 
HFuse = 0xDA 
EFuse = 0xFD 
Lock byte = 0xEF 
Clock calibration = 0xC3 
Type 'L' to use Lilypad (8 MHz) loader, or 'U' for Uno (16 MHz) loader ...
Using Lilypad 8 MHz loader.
Bootloader address = 0x7800
Bootloader length = 1932 bytes.
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...
Verifying ...
No errors found.
Done.
Programming mode off.
Type 'C' when ready to continue with another chip ...

Now, the fuse seems to be 0xFD.
Next I burned the ArduinoISP sketch on the uP on the Uno, changed board to the customer Breadboard one, and Burned the bootloader. This is what I got from the debug output:

First it programs the fuses:

C:\Users\nikosk\Desktop\arduino-1.0.5-r2\hardware/tools/avr/bin/avrdude -CC:\Users\nikosk\Desktop\arduino-1.0.5-r2\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM4 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x07:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xE2:m

among other output I observed the following:

avrdude: reading input file "0x07"
avrdude: writing efuse (1 bytes):

Writing | avrdude: Send: V [56] P [50] . [08] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [fd] 
avrdude: Recv: . [10] 
avrdude: Send: V [56] . [ac] . [a4] . [00] . [07]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
avrdude: Send: V [56] P [50] . [08] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] 
avrdude: Recv: . [10] 
################################################## | 100% 0.06s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x07:
avrdude: load data efuse data from input file 0x07:
avrdude: input file 0x07 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | avrdude: Send: V [56] P [50] . [08] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] 
avrdude: Recv: . [10] 
################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified

So it seems the fuse is correct...

Next it writes the bootloader:

C:\Users\nikosk\Desktop\arduino-1.0.5-r2\hardware/tools/avr/bin/avrdude -CC:\Users\nikosk\Desktop\arduino-1.0.5-r2\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM4 -b19200 -Uflash:w:C:\Users\nikosk\Desktop\arduino-1.0.5-r2\hardware\arduino\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex:i -Ulock:w:0x0F:m

No error is reported and avrdude completes successfully both times.

But when using Nicks' Board detector again I get the following:

Atmega chip detector.
Written by Nick Gammon.
Version 1.17
Compiled on Jul  9 2015 at 01:30:19 with Arduino IDE 105.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x0F 
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = 0xE2 
HFuse = 0xDA 
EFuse = 0xFF 
Lock byte = 0xCF 
Clock calibration = 0xC3 
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 2048 bytes starting at 7800

I would assume that the program detects the efuse wrongly but then again the chip does not run with 3.3 V but only with 5 V so the reading should be correct...

Am I doing something wrong?
Is there a avrdude command to read the fuses?

Thanks in advance,
Nikos

Only bits 0 through 2 are defined. Typically, undefined bits read as one. So, all of these values are equivalent for the extended fuse...

07, 0F, 1F, 3F, 7F, FF

Now, the fuse seems to be 0xFD.

After stripping away the undefined bits is the same as 05.

...the chip does not run with 3.3 V...

How are you powering it when you test at 3.3 V?

I take it from the Uno's 3.3 volt output. As I do when I power it from the 5 volts (again from the Uno 5 volt pin).

You think its not enough power there? I thought so too, thus I tried without any LED (and resistor) by just measuring voltage on the pins.
I get 3.25 Vcc but on pin 13 where the LED is connected I get nothing at all. When in 5 volts I see voltage going up and down on my meter...
Not using any 0.1uF caps on the voltage pins though... You think it can make a difference?
Will give it also a try with an LD1117V33 I'm having...

oh... nice. And I thought I was up to something :smiley:

You think giving a try with another chip makes a difference?