If you are using an Arduino board with an ATmega 328P microcontroller, you may need to set the fuses correctly to ensure proper operation. Fuses are special bits of memory that control various aspects of the chip, such as clock source, brown-out detection, boot loader size, and more. Fuses can be programmed using an external programmer, such as a USBasp or an Arduino as ISP.
In this article, we will show you how to check and change the fuse settings for your Arduino ATmega 328P using the avrdude command line tool. We will also explain what each fuse bit does and what values are recommended for different scenarios.
What are the Fuse Bits for Arduino ATmega 328P
The ATmega 328P has three fuse bytes: low fuse, high fuse, and extended fuse. Each fuse byte consists of eight bits, which can be either 0 or 1. A bit value of 0 means that the feature is enabled, while a bit value of 1 means that the feature is disabled. The default fuse settings for a new ATmega 328P chip are:
Low fuse = 0x62 (B01100010)
High fuse = 0xD9 (B11011001)
Extended fuse = 0xFF (B11111111)
The default fuse settings for an Arduino Duemilanove or Nano with ATmega 328P are:
Low fuse = 0xFF (B11111111)
High fuse = 0xDA (B11011110)
Extended fuse = 0x05 (B00000101)
The difference between these two sets of values is mainly due to the clock source and the boot loader size. The new chip uses an internal 8 MHz oscillator as the clock source, while the Arduino board uses an external 16 MHz crystal. The new chip also has no boot loader, while the Arduino board has a boot loader that occupies 2 KB of flash memory.
How to Check the Fuse Settings for Arduino ATmega 328P
To check the current fuse settings for your Arduino ATmega 328P, you will need an external programmer and the avrdude command line tool. Avrdude is a software that can communicate with various programmers and microcontrollers. You can download it from here.
Once you have installed avrdude, connect your programmer to your computer and to your Arduino board or standalone ATmega 328P chip. Make sure you have selected the correct programmer type and port in avrdude. For example, if you are using a USBasp programmer on Windows, you can use the following command:
avrdude -c usbasp -p m328p
This will tell avrdude to use the usbasp programmer and the ATmega 328P chip. If everything is connected correctly, you should see something like this:
avrdude: AVR device initialized and ready to accept instructions
The last line shows the current fuse values in hexadecimal format. You can convert them to binary format using an online converter or a calculator. For example, E:FF means that the extended fuse is set to B11111111.
How to Change the Fuse Settings for Arduino ATmega 328P
To change the fuse settings for your Arduino ATmega 328P, you will need to use the -U option in avrdude. This option allows you to write new values to the fuses. You will need to specify the fuse byte (e.g., lfuse for low fuse), the memory type (e.g., m for flash), and the new value in hexadecimal format. For example, if you want to change the aa16f39245