Go Down

Topic: How to re-set fuses to 8Mhz internal without an external oscillator (Read 325 times) previous topic - next topic

Primat3

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:

0. 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)


1. 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.

2. From Examples load ArduinoISP.

3. 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.

4. 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

5. Upload your sketch and enjoy.

pegwatcher

#1
Sep 29, 2014, 04:59 am Last Edit: Sep 29, 2014, 05:05 am by pegwatcher Reason: 1
Or you could just buy a 16 mHz crystal for ten cents and then reset the fuses the normal and easy way..  
http://www.taydaelectronics.com/crystals-resonators-oscilliators/16-000-mhz-16-mhz-crystal-hc-49-s-low-profile.html

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.
I'm not a complete idiot. Some parts are missing.

hiduino

#2
Sep 29, 2014, 06:19 am Last Edit: Sep 29, 2014, 06:21 am by hiduino Reason: 1
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, http://www.gammon.com.au/forum/?id=11637
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.


pegwatcher

@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.
I'm not a complete idiot. Some parts are missing.

hiduino

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.

Paul__B


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.   :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!

fungus


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.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Paul__B


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.

pegwatcher

#8
Sep 30, 2014, 03:40 am Last Edit: Sep 30, 2014, 03:44 am by pegwatcher Reason: 1
Quote
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.
I'm not a complete idiot. Some parts are missing.

Go Up