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.

LED Cube 8x8x8

Step 45Program the AVR: Set the fuse bits

Program the AVR: Set the fuse bits
«
  • IMG_6411.JPG
  • hfuse1.png
  • hfuse2.png
  • lfuse1.png
  • lfuse2.png
The ATmega32 has two fuse bytes. These contain settings that have to be loaded before the CPU can start, like clock source and other stuff. You have to program your ATmega to use an external high speed crystal oscillator and disable JTAG.

We set the lower fuse byte (lfuse) to 0b11101111, and the high fuse byte to 0b11001001. (0b means that everything after the b is in binary).

We used avrdude and USBtinyISP (http://www.ladyada.net/make/usbtinyisp/) to program our ATmega.

In all the following examples, we will be using an Ubuntu Linux computer. The commands should be identical if you run avrdude on Windows.
  • avrdude -c usbtiny -p m32 -U lfuse:w:0b11101111:m
  • avrdude -c usbtiny -p m32 -U hfuse:w:0b11001001:m

Warning: If you get this wrong, you could easily brick your ATmega! If you for example disable the reset button, you won't be able to re-program it. If you select the wrong clock source, it might not boot at all.
« Previous StepDownload PDFView All StepsNext Step »
21 comments
May 7, 2012. 5:22 AMenSYS says:
I think lfuse should have been 0b11101110 for external osc to work.
Mar 9, 2012. 4:45 AMwootner says:
Getting the following error can anyone help please :)

C:\>avrdude -c usbtiny -p m32 -U lfuse:w:0b11101111:m

avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
Dec 24, 2011. 10:02 AManurag130 says:
is it possible to use an arduino in place of the ATmega?

Thanks in advance
Jan 1, 2012. 6:30 PMalahamm says:
3 posts up looaluukie says He has one, Check him.
Jan 1, 2012. 7:57 PManurag130 says:
sorry. i must have missed that.

Thank you!
Dec 27, 2011. 3:01 PMNCC_1701 says:
Can you use the AVR ISP In-system programmer Mk2?
Dec 4, 2011. 12:46 AMylan12 says:
i use the extreme burner avr with uspasp
and i this programe i can write fuse bit 0b101000
i need write 0x_ number i want

see in this picture
http://www.siz.co.il/my/oztnfz2adjdk.png

Thank you

ylan
Nov 15, 2011. 7:30 PMjt269 says:
Hi All,

I'm having a problem using a USBASP dongle to program the chip. I am able to set the lfuse ok using avrdude.
However when I then try to set the hfuse to disable jtag it does not work and I get a message that I cannot set the sck period and programming fails.
I have checked all the connections and I am sure I set the lfuse correctly as I have tried 2 different chips just in case.
I have tried usinb the -B function to mess around with clocks but to no avail.

Any advice would be appreciated.

Cheers
James
Oct 20, 2011. 11:49 AMjonas2789 says:
What if i got a programmer from XELTEK, can i Program the AVR on this, instead of building the on-board RS-232 port and programmer? it may be a lil bit difficult for me to get de ISP programmer...
Sep 8, 2011. 2:43 PMkodfjg says:
Guys, i was reading this from January and in April decided to make my own cube.
So, first of all my hands are made from some kind of a**.
I will not post my pictures of boards, it is not so simply looking as here, no 8pin cables, only one cable on one resistor etc.
And now i got a question.
Soldered it all and bought usbASP instead usbtiny.
Problem: first i was doing it wrong, didn't solder normally, then i connected to cube: made special VCC for mega32 and usbASP. Grounded all in Power Block.
When i plug in usbASP in my mac -> get a warning about switching off usb (unfortunately i have only one usb in laptop) because as i understand all schema use more than 0.4 A.
So, what can i do?
Sep 24, 2011. 10:09 AMkodfjg says:
no one likes me.(
Aug 2, 2011. 11:14 PMtbarkin says:
So i was powering the atmega32 from the usbtiny and I was able to set both fuse bits. I entered exactly what was written above (made sure 3 times before doing it) and now I cant program the chip. Any advice?
Aug 25, 2011. 5:00 PMLOBO_76 says:
I had the same problem after setting the lower fuse byte. Spent hours of troubleshooting till I noticed that I had used the wrong capacitors on the 14,7456 MHz crystal . I used the 100 nF instead of the intended 22 nF for c4 and c3. After changing them the, uploading the test.hex file into the µC worked fine.
If you have used the right capacitors my second thought would be that the crystal is damaged .
Aug 27, 2011. 8:11 AM235@F says:
Capacitors 22nF or 22pF???
Aug 29, 2011. 4:25 PMLOBO_76 says:
22 pF

Sorry, my mistake.

Thanks!
Aug 3, 2011. 7:54 PMbkeaton says:
Before we can help you, we would need much more information from you. Can you post a copy of the results of your setting the fuse bits? What about posting the results of your programming attempts? There is no way to tell what your problem is without seeing that information.

I am quite sure someone can help. We just need to see the exact problem.
Aug 9, 2011. 9:15 PMtbarkin says:
So I followed the images in step 45 exactly and got the exact same readouts when setting the fuse bits that are displayed. No deviation what so ever. Right after that the usbtiny could no longer see the Atmega32 so i checked the crystal which is wired correctly. The readout on the cmd is in the links

http://imgur.com/3hKcF
http://imgur.com/skZ8c

I tried changing the speed the usbtiny was reading with the -B # command. Nothing seemed to work there.

(the response device signature = 0x00000000 is the same response to not having the usbtiny connected to anything at all. :(
Feb 21, 2012. 4:14 PMtarPancake says:
did you ever figure this out? i have the exact same problem and have basically bricked 3 atmega 32's now. does anyone else have some advice?
Feb 22, 2012. 2:00 AMtbarkin says:
Sorry dude, Since college started I haven't had the free time so I probably won't look at it again till may unfortunately. I'm going to replace most of the parts and see if i can't get it running. I'll let you know if I have any success then.
Aug 27, 2011. 8:17 AM235@F says:
If I program with Uniprof what to enable Fuse Bits?
And how to check up, whether I have spoiled ports on the microcontroller?
Jan 24, 2011. 7:54 PMelectric11 says:
Can I run this on a Mac?
Jun 15, 2011. 8:54 AMsrichter1 says:
Thats what I am planning on doing. I looking up the USB tinyISP and it has avrdude for mac.
Feb 23, 2011. 12:09 PMkctess5 says:
Id like to know that too, though a dedicated netbook would be nice and only cost around 200-300 dollars
Jun 10, 2011. 2:51 PMVincetacular says:
I have a AVR doper can I use that board to do the programming?
Jan 11, 2011. 12:55 AMnatekling says:
Where is the best place to purchase an ISP? Is the USBtinyISP necessary, or will other ISPs work?

Thank you.

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!
651
Followers
7
Author:chr
I like microcontrollers and LEDs :D