Backend / DevOps / Architect
Brit by birth,
located worldwide

All content © Alex Shepherd 2008-2024
unless otherwise noted

Reading hFuse, lFuse and eFuse from Arduno IDE.

Published
1 min read
image
Image Credit: Unknown (if this is your work, reach out to me and I'll credit you!)

Hi guys!

A real stumbling block, on which I find there is a lot of misunderstanding and misinformation is that of hardware fuses.

These aren't fuses in the traditional sense (protective circuit breakers), they are persistent hardware settings, sort of like a configuration file. I wanted to find out what my Arduino's ATmega328P's fuse settings were, to compare them to the factory defaults supplied in the datasheet. Many people seemed to be saying "It's not possible from the Arduino IDE" or "The Arduino's firmware doesn't have access to those values". Both of these are completely untrue, as there are functions in the Arduino's core libraries which allow you to read them.

Here's the code:

#include <avr>

void setup() {
  Serial.begin(9600);
  int lf = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
  int hf = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
  int ef = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);

  Serial.print("Low Fuse Bits: ");
  Serial.print(lf);
  Serial.print("High Fuse Bits: ");
  Serial.print(hf);
  Serial.print("Extended Fuse Bits: ");
  Serial.print(ef);
}

void loop() {
  // Do nothing
}</avr>

This will print an integer value between 0 and 255 to the serial console. View these in hex and binary on any calculator program to see which bits are set. I've tested it on an Arduino Uno R3, with IDE version 1.0. If you have success with any other models, please let me know, so I can update the article and credit you.

That's all for today!

n00b