Go Down

Topic: How to enable BOD fuse? (Read 1 time) previous topic - next topic

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

bratan


"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"
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info :)

CrossRoads

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.

bratan

#18
Jul 03, 2013, 09:44 pm Last Edit: Jul 03, 2013, 09:51 pm by bratan Reason: 1

I just realized that I can just use Arduino as ISP to program Fuses :)
Since I created Rapid BootLoader shield, it's pretty easy to do it with that...
In case someone finds this useful:
Code: [Select]
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 :)

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: [Select]

avrdude -C c:\programs\arduino\hardware\tools\avr\etc\avrdude.conf -patmega644p -cavrisp -P\\.\COM5 -b 19200 -D -Uflash:w:yourhexfile.hex:i
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info :)

hiduino

#19
Jul 03, 2013, 11:36 pm Last Edit: Jul 03, 2013, 11:40 pm by hiduino Reason: 1


If you interested in uploading sketch without loosing Bootloader use this command:
Code: [Select]

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.


bratan



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.
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info :)

hiduino

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?


bratan

#22
Jul 04, 2013, 03:28 am Last Edit: Jul 04, 2013, 03:31 am by bratan Reason: 1

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 :) 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 :)
I didn't test if setting fuse works with "-D" command, only did hex program upload.
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info :)

hiduino

#23
Jul 04, 2013, 05:27 am Last Edit: Jul 04, 2013, 11:00 am by hiduino Reason: 1
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.


Go Up