Pages: [1] 2 3   Go Down
Author Topic: Standard Fuse Settings for 16Mhz ATMega328p  (Read 15262 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-sad )

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 smiley

regards
Simon
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: September 06, 2011, 03:13:30 pm by dc42 » Logged

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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
boards.txt

Ta smiley
I used the values in there and used my little USBasp programmer with
Code:
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 smiley

Simon
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How about these:

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

Don
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

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

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

Thanks.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

When I use the Arduino IDE to flash the bootloader it always sets the proper fuses without any interaction on my behalf.
Logged

Check out my experiments http://blog.blinkenlight.net

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26523
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been doing the same - burn a Uno bootloader to set the fuses.Then upload my sketch via File :Upload Using programmer.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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.

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: November 05, 2012, 06:12:24 pm by clivemist » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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.

Pages: [1] 2 3   Go Up
Jump to: