Go Down

Topic: Standard Fuse Settings for 16Mhz ATMega328p (Read 21266 times) previous topic - next topic

simplesi

I've finally got myself a virgin ATMega328p and without uploading a bootloader, I've uploaded a simple variation of Blink and thought it was broken until I realised that because I hadn't set the fuses, the MCU was just using internal clock and running at 1MHz intead of 16MHz (I've included a crystal on my board).

So I'm thinking that if I set my fuses to the same as my ATMega328p Uno then I should be OK.

But I can't find what the bytes should be - could someone tell me please (I've given up trying to read them out from my Uno :( )

And of course, if the fuses should be different for a non-bootloader 16Mhz crystal clocked ATMega328p than my Uno, could I have those instead :)

regards
Simon

dc42

#1
Sep 06, 2011, 10:08 pm Last Edit: Sep 06, 2011, 10:13 pm by dc42 Reason: 1
I had exactly the same issue when I programmed my first 328! You can work out the fuse settings you need at http://www.engbedded.com/fusecalc.

PS - If you just want the same ones as used in a standard Arduino, you can find them in the boards.txt file:

uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

simplesi

Quote
boards.txt


Ta :)
I used the values in there and used my little USBasp programmer with
Code: [Select]
avrdude -c usbasp -p m328p -C ../etc/avrdude.conf -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m

and my project imeidiately started running at the correct speed :)

Simon

floresta

How about these:

Fuse calculator:
   http://www.engbedded.com/fusecalc/
Arduino Default Fuses:   http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/

Don

wlewis

Hi,

These setting did it for me too... 16mhz atmega328p.

lfuse = 0xff
hfuse = 0xde
efuse = 0x05

Thanks.

floresta

Have you heard of the phrase "a day late and a dollar short" out there in zeroland?

What has this post (to a stale thread) added that wasn't already said in the very first reply?


Don

clivemist


I had exactly the same issue when I programmed my first 328! You can work out the fuse settings you need at http://www.engbedded.com/fusecalc.

PS - If you just want the same ones as used in a standard Arduino, you can find them in the boards.txt file:

uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05



Hi dc42.

I am getting similar issues as this with a 328p-au..
I've tried alsorts but am a bit stuck:

http://arduino.cc/forum/index.php/topic,129740.0.html

Any ideas?

Thanks in advance.

floresta

Quote
I've tried alsorts but am a bit stuck:


Have you tried either the default values or the values recommended in this thread?

Don

Udo Klein

When I use the Arduino IDE to flash the bootloader it always sets the proper fuses without any interaction on my behalf.
Check out my experiments http://blog.blinkenlight.net

CrossRoads

I've been doing the same - burn a Uno bootloader to set the fuses.Then upload my sketch via File :Upload Using programmer.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

dc42


Hi dc42.

I am getting similar issues as this with a 328p-au..
I've tried alsorts but am a bit stuck:

http://arduino.cc/forum/index.php/topic,129740.0.html

Any ideas?

Thanks in advance.


Looking at your post #7 in that thread, you are setting the baud rate to 300 on the mcu but then you have to set the PC to 2400 to communicate with it. So the UART in the mcu is running 8x faster than it should be. This isn't a problem with the CLKSEL fuse bit, that would cause the mcu to run 8x slower instead.

Are you sure that you have F_CPU set correctly in the boards.txt file you are using? Do you also find that delay and delayMicroseconds calls also execute 8x faster than they should?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

clivemist



Hi dc42.

I am getting similar issues as this with a 328p-au..
I've tried alsorts but am a bit stuck:

http://arduino.cc/forum/index.php/topic,129740.0.html

Any ideas?

Thanks in advance.


Looking at your post #7 in that thread, you are setting the baud rate to 300 on the mcu but then you have to set the PC to 2400 to communicate with it. So the UART in the mcu is running 8x faster than it should be. This isn't a problem with the CLKSEL fuse bit, that would cause the mcu to run 8x slower instead.

Are you sure that you have F_CPU set correctly in the boards.txt file you are using? Do you also find that delay and delayMicroseconds calls also execute 8x faster than they should?



Thanks for getting back to me Don.


From using the calculator I managed to get the baud correct with:

lfuse:w:0x77:m
(I know this is probably incorrect).
..and from messing about trying to set the fuses again I am back to the same issue of the baud reading out incorrectly and chasing my tail..



The board.txt is set to:

--------------------------------------------------------------------------------------

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

uno.name=Arduino Uno

uno.upload.protocol=arduino

uno.upload.maximum_size=32256

uno.upload.speed=115200

uno.bootloader.low_fuses=0xff

uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard

--------------------------------------------------------------------------------------


The following worked when I had the baud reading at the correct rate:

- IDE does not upload
- AVRDude upload via Arduino ISP works
- Upload in IDE via Arduino ISP works
- Serial feedback (TX-RX loop) works [328 bypassed]
- Serial feedback via 328P works
- Holding reset at various times before/during/on upload no dice
- f_cpu=16000000L


I've double checked all my schematics, including the pull down 1k, 100nf cap between the 8u2 and the reset on the 328P-AU.
I have also removed and resoldered these components.

Could this be an issue with the 8u2?
I have managed to run the DFU many times with the same code I uploaded on to my R3 and this still uploads and works.

Thanks in advance for any suggestions!

dc42

So do delay() calls in sketches you upload delay for the correct amount of time or not?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

clivemist

#13
Nov 06, 2012, 12:08 am Last Edit: Nov 06, 2012, 12:12 am by clivemist Reason: 1

So do delay() calls in sketches you upload delay for the correct amount of time or not?



Sorry, got my last post incorrect..

A delay(1000) posts at roughly 1 second. However the baud is mismatched.

dc42



So do delay() calls in sketches you upload delay for the correct amount of time or not?



If you mean in a main body of code, they are not, also my baud is mismatching again..


Do they take too long? or not enough time? By what factor are they wrong?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Go Up