Pages: 1 [2]   Go Down
Author Topic: How to enable BOD fuse?  (Read 1358 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23748
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

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

New York
Offline Offline
Sr. Member
****
Karma: 3
Posts: 362
xronosclock.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info smiley

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23748
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

Alright then.
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.

New York
Offline Offline
Sr. Member
****
Karma: 3
Posts: 362
xronosclock.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I just realized that I can just use Arduino as ISP to program Fuses smiley
Since I created Rapid BootLoader shield, it's pretty easy to do it with that...
In case someone finds this useful:
Code:
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 smiley
HUGE WARNING 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:
Code:
avrdude -C c:\programs\arduino\hardware\tools\avr\etc\avrdude.conf -patmega644p -cavrisp -P\\.\COM5 -b 19200 -D -Uflash:w:yourhexfile.hex:i
« Last Edit: July 03, 2013, 02:51:58 pm by bratan » Logged

Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info smiley

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 27
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


If you interested in uploading sketch without loosing Bootloader use this command:
Code:
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.

« Last Edit: July 03, 2013, 04:40:22 pm by hiduino » Logged

New York
Offline Offline
Sr. Member
****
Karma: 3
Posts: 362
xronosclock.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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.


That was my point, this is supposed to work with Bootloader.
Logged

Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info smiley

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 27
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, it was not clear you were using the bootloader to upload the sketch, since you had to use an ISP programmer to change the fuse bits.

For clarification are you using a custom bootloader to upload at 19200 baud?

Logged

New York
Offline Offline
Sr. Member
****
Karma: 3
Posts: 362
xronosclock.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, it was not clear you were using the bootloader to upload the sketch, since you had to use an ISP programmer to change the fuse bits.

For clarification are you using a custom bootloader to upload at 19200 baud?
Sorry I'm fairly new to AVRs... Are you saying that baud rate depends on type of Bootloader?
I'm using standard Sanguino bootloader with ATMega644p chip. It's a custom board I made so it doesn't have USB onboard. There are basically two ways I upload sketches to it, either by connecting FTDI adapter or uploading sketch to the 644p chip directly with my "Rapid bootloader shield" which basically sits on top Uno R3 and uses it as ISP programmer.  I found 19200 baud option in one example posted on Sparkfun so I'm using it and it works great.
I just find it quicker to upload a chipInfo sketch using Arduino as ISP (right after I burn bootloader), however I want to preserv ability to later upload sketches via FTDI.
I've programmed about ten 644p chips using avrdude with "-e" switch and while all of them appeared to be working, week later I found out that I cannot upload anything via FTID, which almost caused me to loose my mind smiley Then I realized problem was in the method that I was using to upload "test" sketch, it was erasing Bootloader in the process. I experimented with different avrdude switches. Only when I added -D switch I was able to upload sketch via ArduinoISP and keep bootloader intact. It didn't make a lot of sense to me first (since it "disables Erasing before programing"), but after your post I now closer to understanding why it works.
Anyway I got pretty far from my original post about fuses, but I just wanted to give warning to other newcomers who might stumble on this thread in search for answers smiley
I didn't test if setting fuse works with "-D" command, only did hex program upload.
« Last Edit: July 03, 2013, 08:31:08 pm by bratan » Logged

Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info smiley

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 27
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some additional food for thought.  For programming AVRs the two most common are via bootloader and ISP.  There are others but I won't go into that.

For ISP, using external programmer, like ArduinoISP, USBasp, AVRISPmkII, and USBtinyISP.  These will program the AVR flash, eeprom, and fuse bytes.  You can program each individual section without affecting the other.  Fuse bytes can be reprogrammed over and over as needed (I guess there is some kind of internal fuse erasing going on).

For ISP flash programming however, once you flash you cannot flash again without erasing first.  Erasing sets all flash memory locations to ones "1".  Programming sets appropriate bits to zero "0".  Once a bit is zero you cannot program it back to one "1", you need to erase it to change it back to a one "1".

So if you had uploaded a sketch with the avrdude -D option, using ArduinoISP method, then this could be a problem.  If you do this only once right after burning bootloader, then you should be okay, since flash was already erased (from burning bootloader).  But you cannot upload again with this same method using ISP if you already have a sketch in flash.  You will have to erase flash first in order to upload a sketch again.  The issue with ISP programming is that you can only erase all of the flash at a time.

For programming using bootloader, this will only program flash memory.  It cannot burn fuse bytes.  If you upload using bootloader via USB serial FTDI then this method will not erase all of the flash, only what's needed, therefore preserving the bootloader.  The bootloader code will re-program flash memory on a page by page basis.  It will first erase a page (a page size varies from 32 bytes to 256 bytes depending on the AVR) then program a part of the sketch code to it.  In addition there are fuse lock bits available to prevent the bootloader code from overwriting itself.

Since the bootloader is running code and using the serial UART for communication it needs to talk at a specified BAUD rate.  So yes, it is important to know what BAUD rate the bootloader has been compiled to run at.  Most Arduinos use 57600 or 115200 BAUD rates.  For Sanguino boards, they are usually at 57600 or 38400 BAUD rates depending on the mcu speed.  If you need different BAUD rates then you will need to re-compile a custom bootloader for that.

I hope this clarifies some things.

« Last Edit: July 04, 2013, 04:00:13 am by hiduino » Logged

Pages: 1 [2]   Go Up
Jump to: