3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

AVRSH: A Command Interpreter Shell for Arduino/AVR.

Step 3Reading and Writing Fuses

Reading and Writing Fuses
Fuses are special types of registers. They control everything from the clock speed of your microcontroller to what programming methods are available to write-protecting EEPROM. Sometimes you will need to change these settings, especially if you're creating a stand-alone AVR system. I'm not sure you should change your fuse settings on Arduino. Be careful with your fuses; you can lock yourself out if you set them incorrectly.

In a previous instructable, I demonstrated how you can read and set your fuses using your programmer and avrdude. Here, I'll show you how to read back your fuses at run time to see how your MCU has actually set them. Note, that this isn't the compile-time setting that you get from the definitions in <avr/io*.h> but the actual fuses as the MCU reads them at run time.

From Table 27-9 in the ATmega328P datasheet (databook, more like it) the bits of the Fuse Low Byte are as follows:
CKDIV8    CKOUT    SUT1    SUT0    CKSEL3    CKSEL2    CKSEL1    CKSEL0
An interesting thing to note is that with fuses, 0 means programmed and a 1 means that that particular bit is unprogrammed. Somewhat counter-intuitive, but once you know it you know it.
  • CKDIV8 sets your CPU clock to be divided by 8. The ATmega328P comes from the factory programmed to use its internal oscillator at 8MHz with CKDIV8 programmed (ie set to 0) giving you a final F_CPU or CPU frequency of 1MHz. On Arduino's, this is changed since they are configured to use an external oscillator at 16MHz.
  • CKOUT when programmed will output your CPU clock on PB0, which is digital pin 8 on Arduinos.
  • SUT[1..0] specifies the startup time for your AVR.
  • CKSEL[3..0] sets the clock source, such as the internal RC oscillator, external oscillator, etc.
When you read your fuses, it will be returned to you in hexadecimal. This is the format that you need if you want to write the fuses via avrdude. On my arduino, here's what I get when I read the lower fuse byte:
root@ATmega328p> read lfuseLower Fuse: 0xff
So, all bits are set to 1. I did the same procedure on an Arduino clone and got the same value. Checking one of my stand-alone AVR systems, I got 0xDA which is the value I had set some time back when configuring the chip.

The same procedure is used for checking the High Fuse Byte, Extended Fuse Byte, and Lock fuses. The calibration and signature fuse bytes have been disabled in the code with an #if 0 preprocessor directive, which you can change if you feel scrappy.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
62
Followers
22
Author:nevdull(The Bold Scientist)
Gian is the VP Research & Development at Open Design Strategies and holds a BA in Molecular/Cellular Biology and an MS in Computer Science. He has a collection of 8-bit microcontrollers and a room fu...
more »