PDA

View Full Version : AVR Fuse Calculator



crenn
05-16-2010, 09:26 AM
For those with an AVR based microcontroller that you got fresh from the factory, you might want to look at this:

http://www.engbedded.com/fusecalc

Oneslowz28
05-16-2010, 09:32 AM
Thanks crenn! Any chance we might get some explanation of what each setting is?

crenn
05-17-2010, 10:11 PM
I'll post a little tutorial later today on how to calculate what fuses you want.

crenn
05-18-2010, 08:56 PM
Ok, here's a basic tutorial on how to use the fuse calculator for a ATMega168.

Clock source and dividers
You can pick one of 5 clock sources:
Internal Oscillator
External Clock Signal
Low.Freq Crystal
Full Swing crystal
External Crystal Oscillator

For the ATMega168 Development Kit, a 20MHz External crystal is included, so I'd pick the External Crystal Oscillator.

Start-up time
The time taken to start up the processor is picked by this option, I'd pick 65ms to be safe.

Clock Output on Port B pin 0
If selected this will output the clock signal on pin 0 of port B. Unless you need it, don't select this.

Divide clock by 8 internally
If selected this will divide the clock by 8. So if you have the 8MHz internal oscillator, your processor speed will be 1MHz. Don't recommend this option, but it can be useful.

Brownout detection
If Vcc drops below the detect level set, the micro will reset.

Preserve EEPROM memory through the Chip Erase cycle
If selected, the EEPROM won't be erased when the chip is erased.

Watch-dog Timer always on
If selected, the watch-dog timer (which is used to detect if the micro has crashed and needs to be reset) will be always on. You can also turn it on with the registers.

Serial program downloading (SPI) enabled
This is important as this allows you to download the program to the chip via the SPI port. KEEP THIS ENABLED.

Debug Wire enable
Unless you have the debugger, this isn't really applicable. Keep disabled.

Reset Disabled (Enable PC6 as i/o pin)
This makes pin 6 of port C an I/O pin but has a side effect of disabling SPI downloading I believe. Keep this disabled unless this chip is going to be programmed once and then never programmed again. The only way to unset this is by using High Voltage Programmers.

Boot Reset vector Enabled
This tells the micro to go to the boot sector instead of the normal reset vector. KEEP THIS DISABLED UNLESS YOU KNOW WHAT YOU'RE DOING.

Boot Flash Size
This sets the size of the flash. Requires the above to be set to work. This is where bootloaders will be stored. Doesn't really need to be touched.

So with those settings done, I get this output:
Low 0xCF
High 0xDF
Extended 0xF9

So to program with AVRDude, use these arguments
-U lfuse:w:0xcf:m -U hfuse:w:0xdf:m -U efuse:w:0xf9:m

Note
Depending on the programmer, avrdude might say it fails to program the extended bits (efuse) and say the output is 0x06. This is actually normal and fine. There is a note on the calculator page telling you of this.

* Note that some numerical values refer to fuses containing undefined bits (set to '1' here). Depending on the target device these fuse bits will be read either as '0' or '1'. Verification errors will occur if the values are read back with undefined bits set to '0'. Everything is fine if the values read from the device are either the same as programmed, or the following values (undefined set to '0'): Extended: 0x01.