8-bit AVR® Microcontrollers Fuses

Last modified by Microchip on 2023/12/04 15:03

AVR® microcontroller (MCU) 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 and MPLAB X 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).

AVR Fuses Summary

The device has three Fuse bytes. The following tables describe briefly the functionality of all the fuses and how they are mapped into the Fuse bytes. Note that the fuses are read as logical zero, “0”, if they are programmed.

Extended Fuse Byte for ATmega328PB

Extended Fuse ByteBit No.DescriptionDefault Value
-7-1
-6-1
-5-1
-4-1
CFD3Disable Clock Failure Detection0 (programmed, CFD disable)
BODLEVEL2(1)2Brown-out Detector trigger level1 (unprogrammed)
BODLEVEL1(1)1Brown-out Detector trigger level1 (unprogrammed)
BODLEVEL0(1)0Brown-out Detector trigger level1 (unprogrammed)

Note: 

1. Please refer to Table BODLEVEL Fuse Coding in System and Reset Characteristics for BODLEVEL Fuse decoding in the device datasheet.

Fuse High Byte for ATmega328PB

High Fuse ByteBit No.DescriptionDefault Value
RSTDISBL(1)7External Reset Disable1 (unprogrammed)
DWEN6debugWIRE Enable1 (unprogrammed)
SPIEN(2)5Enable Serial Program and Data Downloading0 (programmed, SPI programming enabled)
WDTON(3)4Watchdog Timer Always On1 (unprogrammed)
EESAVE3EEPROM memory is preserved through the Chip Erase1 (unprogrammed), EEPROM not reserved
BODLEVEL2(4)2Brown-out Detector trigger level1 (unprogrammed)
BODLEVEL1(4)1Brown-out Detector trigger level1 (unprogrammed)
BODLEVEL0(4)0Brown-out Detector trigger level1 (unprogrammed)

Note: 

1. Please refer to Alternate Functions of Port C in I/O-Ports chapter for description of RSTDISBL Fuse.
2. The SPIEN Fuse is not accessible in serial programming mode.
3. Please refer to WDTCSR – Watchdog Timer Control Register for details.
4. Please refer to Table. BODLEVEL Fuse Coding in System and Reset Characteristics for BODLEVEL Fuse decoding.

Fuse Low Byte for ATmega328PB

High Fuse ByteBit No.DescriptionDefault Value
CKDIV8(4)7Divide clock by 80 (programmed)
CKOUT(3)6Clock output1 (unprogrammed)
SUT15Select start-up time1 (unprogrammed)(1)
SUT04Select start-up time0 (programmed)(1)
CKSEL33Select Clock source0 (programmed)(2)
CKSEL22Select Clock source0 (programmed)(2)
CKSEL11Select Clock source1 (unprogrammed)(2)
CKSEL00Select Clock source0 (programmed)(2)

Note: 

1. The default value of SUT[1:0] results in maximum start-up time for the default clock source. See the Fuse Low Byte for ATmega328PB table. Start-up times for the internal calibrated RC Oscillator clock selection in Calibrated Internal RC Oscillator of System Clock and Clock Options chapter for details.
2. The default setting of CKSEL[3:0] results in internal RC Oscillator @ 8MHz. See the Fuse Low Byte for ATmega328PB table. Internal Calibrated RC Oscillator Operating Modes in Calibrated Internal RC Oscillator of the System Clock and Clock Options chapter for details.
3. The CKOUT Fuse allows the system clock to be output on PORTB0. Please refer to Clock Output Buffer section in the System Clock and Clock Options chapter for details.
4. Please refer to System Clock Prescaler section in the System Clock and Clock Options chapter for details.

The status of the Fuse bits is not affected by Chip Erase. Note that the Fuse bits are locked if Lock bit1 (LB1) is programmed. Program the Fuse bits before programming the Lock bits.

AVR Fuse Programming in MPLAB® X

Exit Debug Mode

The fuses cannot be programmed while debugging a project.  The debug tool also needs to be disconnected.  Select Debug > Disconnect from Debug Tool as shown.

Disconnect from Debug Tool

Switch communication from debugWIRE to ISP

Right-click on the Project Name in the file explorer window and select Properties and then select OK at the bottom.

Project Properties

If a dialog appears asking if you would like to switch to ISP, select YES.

Switch to ISP

In the next dialog, select the pull down next to Interface and select ISP if not already selected.

ISP Communication Option

 

Select mEDBG and Communication

In the next dialog box, select mEDBG and then scroll to Communication in the Option Categories pull-down menu, and then select OK.

mEDBG_Communication

Disconnect and Reconnect the Device

The power needs to be cycled on the device to restart this communication in ISP mode.  Briefly unplug the device from your PC and reconnect.  You will now be able to read the current status of the configuration fuses.

Read the Fuses

Select Window > Target Memory Views > Configuration Bits.  A new window will appear showing the status of each of the fuses.  They will appear RED until the device is read.  Now select the Read Device Icon in the upper left of the new window.  If successful, the readings will turn to black text.

Read Device Memory

 

Making a Change to the Fuses

Some changes to the fuses can result in bricking of your device.  See the "Bricking a Device" section of this page for more details.

Currently, the fuses are configured to turn off the Watch Dog Timer.  We know this because in the WDTON row, the setting indicates CLEAR. We will turn it in on in the following example by changing it to SET.

The WDTON option is set by the High Fuse setting of bit 4.  The High Fuse currently has a hex value of 0xDF.  If we change bit 4 to a 0, the hex value becomes 0xCF. 

Create a new project or add the following code toward the top of an existing project (just below the #include statements)...

//Set Fuses to configure the device
FUSES = {
 .low = 0xE0, // LOW {SUT_CKSEL=EXTCLK_6CK_14CK_65MS, CKOUT=CLEAR, CKDIV8=CLEAR}
.high = 0xCF, // HIGH {BOOTRST=CLEAR, BOOTSZ=256W_3F00, EESAVE=CLEAR, WDTON=SET, SPIEN=SET, DWEN=CLEAR, RSTDISBL=CLEAR}
.extended = 0xFE, // EXTENDED {BODLEVEL=1V8, CFD=CFD_ENABLED}
};

Press the Make and Program device button and your new Configuration bits should reflect that the WDTON is now set.

WDTON is SET

Other fuses can be assigned SET or CLEAR in the same manner. 

AVR Fuse Programming in Atmel Studio

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

Device Programming Icon

Menu Selection

Device Programming Menu Selection

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

Device Programming Window

 

Select the Fuses option

The Fuses pane 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.

Device Program Fuses

 

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.

A fuse bit that is selected is set to 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 in 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 MCU.

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

Fuse Low Byte

  • 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

Fuse Hight Byte

  • 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

Fuse Extended Byte

  • 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