-1

I need to use an external crystal oscillator for PWM generation on the ATmega1284P. I have set the wrong fuse bits and I can't program it now. Can this be rectified?

user170667
  • 13
  • 4

1 Answers1

0

Sorry for my previous short answer, the answer here is from this website [TUT][SOFT] Recovering from a "locked out" AVR

Since the wrong values of fuses that you have set are not provided, and since the problem is related to external oscillator I will assume that you have set the clock source of atmega1284P in a wrong way, the problem you may have is that you have set CKSEL fuses to choose some form of external clock that isn't present. The solution to this problem is to apply a clock source to XTAL1 pin of your atmega1284P, and THIS CLOCK SOURCE IS NOT YOUR CRYSTAL, when you apply this clock source you will be able to re-set the fuses in the right way and get CKSEL set back to its intended value, another note: the ISP must always run at less than 1/4 of the clock frequency of the AVR. So if you apply a 1MHz clock signal to the XTAL1 pin then the ISP programmer must be set to run at 250kHz or less. Possible sources of such clock signal are:

1) an STK500. This has an on-board clock circuit. In AVR Studio, when you connect to the STK500, you can program this clock to some division of 3.6864MHz.

2) an STK600 has a very similar clock circuit though its upper frequency limit is higher than the STK500.

3) an NE555 can easily be wired up with a handful of components to generate about 1MHz.

4) another AVR can be used if you load a program such as:

#include <avr/io.h>

int main(void) {
    DDRB = 0xFF;
    while(1) {
        PORTB ^= 0xFF;
    }
}

this will toggle all the pins on PORTB as fast as possible. Anyone of those PORTB pins (together with a common GND) can be connected to the AVR that needs to be recovered.

5) Use a frequency generator set to square wave and something around the 1MHz mark (could be faster if you like)

Another potential clock problem is where you attach a crystal (with caps), set the correct CKSEL fuses and it still will not oscillate - this may be caused by not setting the CKOPT fuse or selecting "Full swing" when the crystal is 8MHz or more. This mode of operation uses more power (which is why it's not selected by default) but is required to get higher frequency crystals to resonate correctly. If the AVR is in this situation the foregoing technique should also recover it.

This website give you an easy tool to figure out the right fuses for your setup: Engbedded Atmel AVR® Fuse Calculator

If you describe your problem in more detail I will be more able to help you.

Moutyam
  • 16
  • 1