How to enable BOD fuse?

I'm using my custom Sanguino (ATMega644p) based board.
I've had some issues with loosing data stored in EEPROM due to bad power connector, however now I'm seeing much worse issues when program in Flash gets corrupted! It happens very rarely (so far I've seen it twice in 3-4 months), every time when power is interrupted (i.e. DC plug wiggled). Program is either gone or corrupted, re-flashing it back solves the problem.
I've see other people reporting this issue, and many recommend enabling Brown Out Detection (BOD).
I'm looking for a guide how to enable it on ATMega644p w/ Sanguino bootloader/hardware definition.
Guessing I need to modify boards.txt file, specifically this line:

atmega644.bootloader.low_fuses=0xFF
atmega644.bootloader.high_fuses=0x9A
atmega644.bootloader.extended_fuses=0xFF

I know about fuse calculator site (not sure exactly which values I need to choose), so using it I can change above values, but do I need burn Bootloader again in order for them to be active in the chip?
From above values, any way to tell what it's set for right now?
Anything I need to do?

I don't know about the calculator site, where is it??? That would sure be easier.

Anyway, to the best of my knowledge, yes you have to burn the boot-loader again to set the fuses. avrdude.exe should be able to tell you the current value for the fuses for a chip that doesn't have that stuff locked out.

I don't know why ArduinoISP can't burn them, does anybody else know???

afremont:
I don't know about the calculator site, where is it???

This is the one I use...
http://www.engbedded.com/fusecalc

afremont:
I don't know about the calculator site, where is it??? That would sure be easier.

Anyway, to the best of my knowledge, yes you have to burn the boot-loader again to set the fuses. avrdude.exe should be able to tell you the current value for the fuses for a chip that doesn't have that stuff locked out.

I don't know why ArduinoISP can't burn them, does anybody else know???

Calculator is on this site
I just figured out that typing in values manually will show which values are set, so that part is clear :slight_smile:
So I do have to burn bootloader. That's ok, thank you! :slight_smile:
There are 3 BOD levels, which would be recommended to select? One that's set to 4.3V?
Edit: I tried 4.3V and it would reset all the time when powered by FTDI (strange, should be 5V). So I set it to 2.7V seems stable...

I would think that finding out why the BOD is failing has a bigger priority than crippling it or do you run at the 8 MHZ clock speed? That might be an issue @ .. 2.8V 2.9V and a 16 MHz clock. I regularly put code in 328's 16 MHz and 3V3 which is on the edge, some say beyond but I'd never use a controller that far out of spec.

bratan:
There are 3 BOD levels, which would be recommended to select? One that's set to 4.3V?
Edit: I tried 4.3V and it would reset all the time when powered by FTDI (strange, should be 5V). So I set it to 2.7V seems stable...

4,3V BOD has troubles working against USB Pwr and is very sensible , let's say it's on the hi end, more a 4,9 than a 4,3, I had my share of trouble trying out The BOD options.
BTW if you use avr-dude it's easy to program just the fuses without changing the program flash

bratan:
I've had some issues with loosing data stored in EEPROM due to bad power connector, however now I'm seeing much worse issues when program in Flash gets corrupted! It happens very rarely (so far I've seen it twice in 3-4 months), every time when power is interrupted (i.e. DC plug wiggled). Program is either gone or corrupted, re-flashing it back solves the problem.
I've see other people reporting this issue, and many recommend enabling Brown Out Detection (BOD).

I recommend fixing the power connector instead...

saposoft:
4,3V BOD has troubles working against USB Pwr and is very sensible , let's say it's on the hi end, more a 4,9 than a 4,3, I had my share of trouble trying out The BOD options.
BTW if you use avr-dude it's easy to program just the fuses without changing the program flash

Oh cool! Can it be done via USB? I don't have dedicated ISP, and use Arduino as ISP...

fungus:
I recommend fixing the power connector instead...

I did all I could. Using highest quality silver plated DC sockets and quality DC adapter with good plug. Issue did occur with inferior parts... That should probably reduce chances of such issue almost to 0. But enabling BOD will add another layer of protection, so I think it should be good enough :slight_smile:

bratan:
Oh cool! Can it be done via USB? I don't have dedicated ISP, and use Arduino as ISP...

Just Look in the avr-dude manual

saposoft:

bratan:
Oh cool! Can it be done via USB? I don't have dedicated ISP, and use Arduino as ISP...

Just Look in the avr-dude manual

It refuses to change high fuse bit :frowning:

F:\>F:\Programs\WinAVR\bin\avrdude -patmega644p -cstk500v1 -P\\.\COM3 -b57600 -U
 efuse:w:0xfd:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x1e960a
avrdude: reading input file "0xfd"
avrdude: writing efuse (1 bytes):

Writing |                                                    | 0% 0.00s ***faile
d;
Writing | ################################################## | 100% 0.13s

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

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0xfd != 0x00
avrdude: verification error; content mismatch

avrdude: safemode: efuse changed! Was fd, and is now 0
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xed

avrdude done.  Thank you.

You have the wrong baud rate for Arduino as ISP, should be -b19200.

hiduino:
You have the wrong baud rate for Arduino as ISP, should be -b19200.

I'm not using Arduino actually...
Tried 19200 it's not working at all at that baud :frowning:
avrdude: stk500_getsync(): not in sync: resp=0x00

What kind of programmer are you using ?

You can't program any fuses or bootloader using the FTDI. You need to use an ISP programmer.

I just realized that I can just use Arduino as ISP to program Fuses :slight_smile:
Since I created Rapid BootLoader shield, it's pretty easy to do it with that...
In case someone finds this useful:

avrdude -C S:\programs\arduino\hardware\tools\avr\etc\avrdude.conf -P COM11 -b 19200 -c avrisp -p atmega644p -v -e -U efuse:w:0xfd:m

I verified it works great. Just replace path to avrdude.conf and COM number to your environment :slight_smile:

"efuse:w:0xff:m"

Only the lower 3 bits are programmable in the '328P extended fuse byte.
111 = no brownout detection (0xFF, or 0x07)
110 = 1.8V (0xFE or 0x06)
101 = 2.7V (0xFD or 0x05)
100 = 4.3V (0xFC of 0x04)

CrossRoads:
"efuse:w:0xff:m"

Only the lower 3 bits are programmable in the '328P extended fuse byte.
111 = no brownout detection (0xFF, or 0x07)
110 = 1.8V (0xFE or 0x06)
101 = 2.7V (0xFD or 0x05)
100 = 4.3V (0xFC of 0x04)

Oops it supposed to be "efuse:w:0xfd:m"

Alright then.

bratan:
I just realized that I can just use Arduino as ISP to program Fuses :slight_smile:
Since I created Rapid BootLoader shield, it's pretty easy to do it with that...
In case someone finds this useful:

avrdude -C S:\programs\arduino\hardware\tools\avr\etc\avrdude.conf -P COM11 -b 19200 -c avrisp -p atmega644p -v -e -U efuse:w:0xfd:m

I verified it works great. Just replace path to avrdude.conf and COM number to your environment :slight_smile:

HUGE WARNING [/color]to anyone who uses above command to actually upload HEX sketch to the chip!!!!
As I just discovered it erases Bootloader! Apparently because of the "-e" switch and lack of "-D" switch.
If you interested in uploading sketch without loosing Bootloader use this command:

avrdude -C c:\programs\arduino\hardware\tools\avr\etc\avrdude.conf -patmega644p -cavrisp -P\\.\COM5 -b 19200 -D -Uflash:w:yourhexfile.hex:i

bratan:
If you interested in uploading sketch without loosing Bootloader use this command:

avrdude -C c:\programs\arduino\hardware\tools\avr\etc\avrdude.conf -patmega644p -cavrisp -P\\.\COM5 -b 19200 -D -Uflash:w:yourhexfile.hex:i

No this will not work correctly from ISP programming. You will see it will not work once you change your program. Try adding a line to you code and then re-upload it with that command again. It will probably not work anymore.

The flash memory cannot be programmed to back to a "1" once it is programmed to a "0" unless you erase it. The -D option only works with a bootloader because it does a page erase at a time instead to reprogram. If you reprogram via ISP then the only way is to erase all flash first.