AVR® Fuses

AVR® Fuses are the locations in non-volatile memory that define the hardware configuration of an AVR device.

Fuses are placed in a select section of memory and consist of a few registers. Each bit of the register represents a different fuse setting. Detailed information on which fuses are available in the different programming modes and their functions can be found in the device datasheet. Instruction clock speed, watchdog timer, and debug mode are just a few of the fuse settings available on most devices.

Fuses are changed at programming time with a connected programmer such as the ICE Debugger/Programmer, using Atmel Studio 7 IDE. They are latched in place after programming and also at the power-up of the device.

Unless careful consideration is given to which Fuse bits are programmed, it is easy for the novice programmer to brick their device (i.e. render the MCU un-programmable/un-debuggable in his/her application circuit).

Brief AVR Fuses Summary

Fuse Programming

The Device Programming window (also known as the programming dialog), gives you the most low-level control over the debugging and programming tools. With it, you can program the device's different memories, fuses and lock bits, erase memories, and write user signatures. It can also adjust some of the starter kit properties, such as voltage and clock generators.

The programming dialog is accessible from the Device Programming icon on the standard toolbar or in the Tools > Device Programming drop-down menu selection.

Device Programming Icon

programavr.png

Menu Selection

programavr2.png

The Device Programming window will appear with various programming options listed on the left.

programavr3.png

Select the Fuses option, and the fuses page will appear showing the fuses of the selected device. Fuse settings are presented as checkboxes or as drop-down lists. The Fuse register settings also appear in the lower pane as hexadecimal values.

programming_fuses.png

Read

Press the Read button, in the lower right corner, to read the current value of the fuses. If the "Auto read" box is checked, the fuse settings will be read from the device each time you enter the fuse page.

Change

The fuse settings can be changed via the dropdown boxes. Some selections require a box to be checked or unchecked.

Note: A fuse bit that is selected is set to a "0" in the register.

Program

After any changes are made to the settings, press the Program button to write the current fuse setting to the device. If the "Verify after programming" box is checked, the settings will be verified after a programming operation is completed.

Latch

The fuse values are latched when the device enters programming mode, and changes of the fuse values will have no effect until the part leaves the Programming mode. This does not apply to the EESAVE Fuse, which will take effect once it is programmed. The fuses are also latched on Power-Up in Normal mode.

Adding Fuse Settings to .elf Production File

The Fuse API allows a user to specify the fuse settings for the specific AVR device for which they are compiling. These fuse settings will be placed in a special section in the ELF output file after linking.
Programming tools can take advantage of the fuse information embedded in the ELF file, by extracting this information and determining if the fuses need to be programmed before programming the Flash and EEPROM memories. This also allows a single ELF file to contain all the information needed to program an AVR.

Adding Fuse Settings to main.c

Fuse settings can be added to the main.c using the procedure described here.

Converting Studio .elf format to .hex for Programming with MPLAB® X Tools

If you look at the build output in Studio IDE, you’ll see how the .hex file is made from the .elf file, e.g.:

"E:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "ATtiny416.elf" "ATtiny416.hex"

This means: make the .hex but discard .eeprom, .fuse, .lock, .signature, and .user_signature files.

If you want a HEX file with those sections left over for use with MPLAB X IDE programming tools, make a post-build step, e.g.:

"$(ToolchainDir)\avr-objcopy.exe" -O ihex -R .eeprom -R .lock -R .signature -R user_signatures "$(OutputDirectory)\$(OutDir)\$(OutputFileName)$(OutputFileExtension)" "$(OutputDirectory)\$(OutputFileName).with-fuse.hex"

The reason for the post-build is that Atmel Studio considers .elf as the production file, as does the 'classic AVR environment,' while the MPLAB X environment uses .hex files.

Bricking a Device

The following fuse bytes (and default fuse bit settings) are shown for the ATmega328PB. Key fuse bit settings which could brick the device are highlighted:

FUSE LOW Byte

R/P-0 R/P-1 R/P-1 R/P-0 R/P-0 R/P-0 R/P-1 R/P-0
CKDIV8 CKOUT SUT1 SUT0 CKSEL3 CKSEL2 CKSEL1 CKSEL0
bit 7 bit 0
  • CKSELn [n=3:0] – Selects clock source for the system clock.
  • SUTn [n=1:0] - Selects the delay period from when the External Reset is released (not active anymore) until the Internal Reset is released.
  • CKOUT – Enables clock output on PB0.
  • CKDIV8 – Configures the CPU clock to be pre-scaled by 8.
  • Fuse bit = 1 is un-programmed (inactive/disabled).
  • Fuse bit = 0 is programmed (active/enabled).

FUSE HIGH Byte

R/P-1 R/P-1 R/P-0 R/P-1 R/P-1 R/P-0 R/P-0 R/P-1
RSTDISBL DWEN SPIEN WDTON EESAVE BOOTSZ1 BOOTSZ0 BOOTRST
bit 7 bit 0
  • BOOTRST - If you use a bootloader to flash MCU, this bit must be enabled.
  • BOOTSZn [n=1:0] - These bits select the bootloader section size.
  • EESAVE – Exclude the EEPROM during a chip erase procedure.
  • WDTON – Enable Watchdog Timer by HW.
  • SPIEN – Enable/Disable In-Circuit Serial Programming (ISP) mode.
  • DWEN – Enable/Disable DebugWire debug interface.
  • RSTDISBL – Enable/Disable nRESET pin usage as IO.

FUSE EXTENDED Byte

U-1 U-1 U-1 U-1 U-1 R/P-1 R/P-1 R/P-1
- - - - - BODLEVEL2 BODLEVEL1 BODLEVEL0
bit 7 bit 0
  • BODLEVELn [n=2:0] - They select the brown-out voltage level when the VDD supply is no longer suitable for operation and the MCU is reset.

 Learn More

 
Help! I've Bricked my MCU!
Learn more >
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.