Howto recover wrong fuses settings on a AVR
Yesterday, I ran into a issue with an ATMega32. In fact, I wanted to disable the Jtag support on the chips because I need to use the pins used by the Jtag (PC2-PC5). To disable the Jtag, you simply need to change some fuses. I changed the fuses with the help of the Avr Fuse Calculator, but I messed my ATMega with the wrong clock source. I don’t know how, but I choose the low freq clock. So my ATMega was totally frozen, as the clock settings was wrong, I was unable to reflash it, and worst, unable to change the fuses.
After a little googling, I found there is 3 ways to fixe this kind of issue:
- Use a Jtag (as it doesn’t need a clocked micro)
- Use a high voltage programmer (you can erase the fuse, with a programmer that do a parallel programming with RESET plug to a 12v PSU). This kind of programmer aren’t really easy to find. The only one I know right now is the STK500
- Use an external clock (This is what I used, and describe here)
As, I don’t have any Jtag, or STK500, the only way to fix that is to use an external clock. In fact, I decided to ask on the #avr channel on freenode. And a really kool guy (”rue_mohr”) give me this tips. On every AVR micro, you can use a external clock if you messed the fuses settings. Simply plug a external clock on the clock pin (XTAL1 on the Mega32), and changes the fuses by this way.
Of course, you need a external clock at something like 1Mhz. Of course I don’t have this kind generator at home, but this can be easily done with another AVR micro this something like this:
void main()
{
DDRA = 0xFF;
while (1)
{
PORTA = ~PINA;
nop(); // added some nop, to slow the clock a bit
nop();
}
}
- IV-18 VFD vacuum Russian Clock (part 1)
- Nixie clock at home ?
- IV-18 VFD vacuum Russian Clock (part 2)
- IVL1-7/5 Russian Vacum Tube (VFD) Clock – Part 1
- Lumex Graphic LCD 128×64 (S12864GSF) + AVR (Atmega32)
admin April 15th, 2007
- Electronics
- Comments(24)
How about my problem?
i have the same problem but i use atmega8535, assembly.
thank’s.
Moses just me this link on his weblog, but due to baysien filters, the url have been filtered. This post fix that issue.
Evil Mad Scientist
Thanks Mose
This really works, Thanks. I tried with an attiny13 and this code to simulate 1Mhz clock. Only i needs to set the ISP Freq. on the programmer to lowest rate (51.1hz) that is more slower but works.
Thanks a lot for the tip. It really helped!
i’d like to know if I need only set the external clock and the default values back, or I need make anything else
Santiago, you need to set the right fuse (clock, reset flag etc ..)
I was wondering.. can I use a similar method if I can only get a 32hz instead of 1mhz input? I have 3 atmega168 AVR that are unusable due to some fuse setting.. We switched tabs between fuse writes & now we can’t program/erase the chips any more.
I meant 32khz not 32hz..
I don’t know .. You should give it a try.
What do you mean?
You only have to feed EXTCLK on X1 & that’s it or you has to do so when you gonna program it?
i am using atmega 1281 with stk500/501.
Kindly clear me, how to configure fuse bits.
i am not able to download my program onto the chip, as i have changed some fuse settings..
Thanks.
prag, re-read this howto perhaps :)
It’s possible to have this code (down) in assebly?????
// Library includes
#include
#include
int main()
{
DDRB = 0xFF;
while (1)
{
PORTB = ~PINB;
asm volatile(”nop”);
asm volatile(”nop”);
// _delay_ms(1000); // Uncomment this line to probe if something is live :)
}
return 0;
}
thanks
hi thanks for your greatfull website; i want to khnow how can i access to the program of locked ic(atmega8l) &my programmer is universal2000. thanks
For me it worked perfectly just using CKOUT of another microcontroller(attiny2313).
I do not have any other microcontroller, what if using the LPT printer port? please give this code to generate clock using LPT parallel port … thanks
I found a website that sells a programmer to fix any avr. It only cost $29 and I fixed all of my locked atmega’s!
http://www.microcontrollerprog.com
I had used this way to recover wrong fuses settings on my AVR (ATmega8, ATtiny13) and it had worked perfectly. After then, I set wrong fuses again, I used this way to recover but it didn’t worked. I don’t know why, could you help me?
HI!
I have a worst problem. I work with a atmega 8/16/32 and use a AVRISPmkII to program them.
But the problem occurs when some uC has the SPIEN fuse in ‘1′.(serial programming disabled).
What can I do to fix this problem? I have a great amount of this uC.
Please help me!!!
Dolphin : Perhaps you need to explain, what you screw up ..
Arimarjul : You have to use a parallel programming mode .. this can be done with a STK500, or a JTAG if you don’t break the Jtag enable fuse ..
The parallel flash is the ultimate one, but this require to have a special programmer like the STK500..
I mean that I can’t use this way to recover my AVR which has been recovered before (more clearly, I can use this way only one time). This is my programmer : http://www.lancos.com/prog.html . So, this is my problem.
Thanks.
I had bricked 2 Atmega8’s and used the external clock method with this code running on another atmega8:
#define F_CPU 1000000UL /* 1 MHz CPU clock */
#include
int
main (void)
{
DDRC = _BV (PC0); /* PC0 is digital output */
while (1) /* loop forever */
{
/* set PC0 on PORTC (digital high) */
PORTC &= ~_BV(PC0);
}
return (0);
}
I then connected pin 23 if the working avr to pin 9 of the bricked avr and then restored the fuses. Worked for me on the 2 I screwed up… maybe it will help others
used AVR studio to compile.
The #include should be < avr/io.h >
Thank you for posting this! Rather than program another microcontroller, you can use a standard crystal oscillator circuit, such as one of these – http://z80.info/uexosc.htm – to coax the AVR back to life.