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();
   }
}


Related Posts

46 thoughts on “Howto recover wrong fuses settings on a AVR

  1. How about my problem?
    i have the same problem but i use atmega8535, assembly.
    thank’s.

  2. 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.

    // 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;
    }
    

  3. i’d like to know if I need only set the external clock and the default values back, or I need make anything else

  4. 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.

  5. 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?

  6. 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.

  7. 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

  8. 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

  9. For me it worked perfectly just using CKOUT of another microcontroller(attiny2313).

  10. 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

  11. 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?

  12. 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!!!

  13. 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..

  14. 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.

  15. Hi,
    I was using UniPro10 programmer from ucmicrosystems for programming of ATmega32. But this programmer went bad. I tried to program the same ATmega32 chip with PonyProg (Through Serial Port of PC). It is giving error “Device missing (-24)”. Also I am not able to erase it. But the same programmer i.e. Pony Prog is working well with fresh Atmega32. Can I recover my old Atmega32? Plz help.

  16. Thanks ,thanks , thanks a lot.
    I required 2Atmega16 and 2 atmega 32 with this method.
    Perfectly worked for me .

  17. Thanks heaps! I found it was to also easy to use a spare 8mhz clock crystal lying around. Just manually touch the 2 pins of the crsytal to your xtal pins and then set the fuses. I wiped the fuses on four 44TQFP AVRS on assembled boards with a dodgy elf file, and with a little squinting could fix them just by holding the clock crystal pins against the soldered joints just long enough to change the clock back to internal RC.

  18. i have programmed the above program in atmega32 from where i can take the clock output to give into another atmega as a external clock

  19. i am using extreme burner to burn the program(written using codevision compiler) into an atmel mega 32 chip. i dont have a clue as to how to set the low and high fuse bits in the extreme burner. how to understand which clock frequency must be set?? i am new to this. please help !!

  20. Thanks a Ton guys, this just works perfect, awesome find, i just recovered my bricked Atmega32 soldered on a board by touching the XTAL 1 pin to another uC generating a 4 MHz clock and re writing the Fuse using using the SPI programmer. Great work.

  21. This did not work for me on a ATtiny2313 with either 1Mhz or 4Mhz.
    I accidentally inverted the low/high fuses (wrote L:DF, H:64), thus disabling the external reset.

    Anyone with a similar scenario have any success ?

  22. hi kpax, I am a newbie to uC, I have bricked a quadcontroller board with atmega48pa .can you help by submitting a detailed schematic diagm of how you actually do this, and what frequency is required for atmega48pa….

  23. Thank you very much, my three chips can now be used again,

    This code in Bascom:

    $regfile = “m8def.dat”
    $crystal = 16000000

    Ddrc.5 = 1

    Do
    Portc.5 = Not Portc.5
    nop
    nop
    Loop

    End

  24. Pardon for my ignorance,One of my atmega32 is not working when i tried to set fuse bits
    in extreme burner AVR software.I tried to set fuse bits such that it uses an external crystal clock source. i.e. set high byte 89 and low byte FF.
    but after programming when i tried to read contents the software shows error like this
    “Powering on failed
    cannot able to communicate with target chip…”
    and i does not changed SPIEN value,
    please tell how to recover the chip.
    thanks in advance.

  25. hello. i have used this method for ATmega16 and ATtiny2313 and it works. i have AVRPROG usb2 programmer (is polish i think) thank you. best regard

  26. i have placed 8Mhz external crystal.how can i do the settings of fuse bits for that???..help..

  27. Hi
    I’am programming the atmega32 and I have a problem with the FUSES. I intented to program the MCU with a crystal of 8Mhz. I program the FUSES: Hfuse>0xC9 and Lfuse>FF. Nothing happened. Afther I program the Fuses: Hfuse>0xD9 and Lfuse>FF. Nothing happened.
    The MCU programmer is AVRISP.
    I don’t understand. Would you mind explaining that further?

    The system where I have programming is LCD and USART.
    The fuses got from the datasheet atmega32.

    Thanks.

  28. Hi,i am using atmega 32 microcontroller for serial transmission and reception with the pc using rs 232 interface.How to use the external clock {16mhz} to synchronize the data wat i sent .I was getting some mistakes whenever i used external clock using khazama programmer tat microcontroller cannot be programmed further as it got disabled whenever i used external clock in setting in khazama programmer.So what might me the issue???.Help me out.

  29. Hi There,

    i also have a problem on my atmega32. im trying to fix my bad fuse. can you make the circuit diagram the way you fix your avr?

    Regards
    Darwin

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>