My ATMEGA8 does not respond any more :-( Please advise

Oh, man…I was doing embedded tutorial #3 on changing the fuse bits for my ATMEGA8-16PU to use 16Mhz external crystal…

Before wiring up the crystal and the caps in, avrdude read the fuse bits correctly on my ATMEGA8-16PU (16Mhz max.) and output two bytes, 0xe1 and 0xd9 in that order. Then I turned off the power and wired the crystal in and avrdude wrote 1 byte of lfuse, byte 0xE6, as well as verified it. Now the LED does not blink at all!

I attempted to do a read again and get the below.

avrdude: AVR device not responding

avrdude: initialization failed, rc=-1

Double check connections and try again, or use -F to override this check.

AVRDude now says my ATMEGA8 device signature is 0xffffff. The correct device id is 0x1E9307.

avrdude: Device signature = 0xffffff

Please help!

I don’t have my datasheet handy so I can’t check to be 100% certain, but…

There are two things that could be wrong:

  1. you set it up to use a crystal but haven’t installed the crystal correctly.

  2. You set it up to use an external oscillator instead of a crystal.

The first is easiest to fix. make sure you have the crystal connected between the two correct pins, and that you have the two load capacitors connected between the crystal leads and ground. Something around 18pF should be OK, it tends to not be too critical to oscillate at least a bit :slight_smile:

The second is a bit of a bugger. If you mucked up the oscillator fuse then you can’t program the chip with an ISP any more. You’ll either need to provide a clock from a signal generator or similar to the OSC1 pin yourself, or use a high-voltage serial or parallel programmer. It’s a pain, but not the end of the world.

Ok, thanks mkissin. It sounds like my problem could be number 2, although I am such a newbie to understand completely, but I guess I will dig.

Some more info:

  1. I use the AVR-PG2 (parallel) programmer bought from sparkfun.com.

  2. My AVRDude runs on WINDOWS Vista.

I have been reading, and there are posts that says the parallel port must be configured bi-directional, that is, with ECP and EPP on–whatever that is. This could be red-herring, but wondering if it’s also a possibility of the parallel port not keeping up with the now 16Mhz Mega8, whose fuse bits I changed.

  1. When I use the -F (force) option with AVRDude I am able to program the mega8 BUT’s not fails to verify the stuff written to the mega8 and is still not able to identify the mega8 correctly.

I will try your suggestion on item 2 and also see if I write back the fuse bits to have the mega8 run at 1Mhz.

thanks again.

P.S. If I found a solution, I sure will post…But it’s gonna be a long time :slight_smile:

Well, I’m impressed that you got Vista to play nicely with the parallel port at all! My experiences with that have been less than stellar.

I’m not 100% on how AVRDUDE works, but it looks like -F makes it ignore the device signature. That will simply be masking the problem. The device isn’t returning a wrong signature, it’s simply not returning anything (which AVRDUDE interprets as 0xFF) because it’s not oscillating. I’m fairly sure that’s your problem.

Some of the Olimex AVR programmers (the USB ones, IIRC) include an oscillator on the ISP pin3 specially for this kind of circumstance, which should tell you that it’s not at all uncommon!

I’m guessing you don’t have access to an STK500, or similar. In which case, your best bet is to whip up a quick oscillator. The datasheet says that for clocks under 12MHz, you need to run the clock at a minimum of 4 times the ISP programming rate. AVRDUDE allows you to use the -B option to specify the programming rate, so set it to something low like 20kHz (I’m not sure how, the docs are a bit fuzzy on this option), and make a 100kHz oscillator from a 555 or opamp circuit and poke that into the OSC1 pin of your AVR.

I hope you can get it working again!

ok wait, I finally dug out the datasheet for the mega8 and you’ve set the fuse bits to something completely whack. Fortunately for you, it’s much easier to fix! Initially I was looking at the mega88 datasheet, but it turns out these have actually changed between the two chips.

You’ve set the clock source to an external RC oscillator, in the range 1 to 3MHz.

Just put a 1nF cap from OSC1 to ground, and a 370 ohm resistor from OSC1 to Vcc.

That should get you up and running again. Let me now if it helps.

Hi mkissin!

You’re incredible! I have been searching all over the net and the best thing I found was the site http://blog.louic.nl/?p=161. I tried the recipe and does not work. AVRDude just gets stuck when it asks me to press ‘y/n’ to go on.

But your solution works RIGHT THE WAY! Holy cow! That’s incredible! This is like magic! I am speechless. I am a 20 years software engineer and just started as hobby with electronics. I am telling ya…Software is much easier :slight_smile:

Could you kindly explain to me how that works or point me to the documentation?

THANKS SO MUCH!!!

basically we provide a pull-up resistor to kick start the ATMEGA8’s internal RC oscillator? But why 370 ohm not 10k ohm and why/how would the pull-up resistor help? And the 1nF cap is just smooth things out?

Sorry for such newbie questions.

Remain calm. You’re going to give yourself skin failure. (Simpsons reference). I’m pleased we got your chip oscillating again though. It’s always sad to brick one.

The situation is not as complex as you’re making it out to be. You had just set the oscillator fuse bits to something particularly bizzare (I have never seen anyone actually use the external RC oscillator option, and I guess it was very uncommon, as it seems to have been removed from the mega88 family of chips). I’ll be really explicit about the explanation, so I apologise in advance if it sounds like I’m being condescending at any point

Righto, you said that you set the low fuse byte to 0xE6. That’s 11100110 in binary.

If you check page 221 of the datasheet, you want the least significant 4 bits for CKSEL0…3, as these set the clock options. So, you set them to 0110.

Then on page 24, we can see that falls into the range specified for the external RC oscillator options (values 0100 - 0001).

Page 27 gives us the final option that you selected: a 0.9 to 3.0MHz external RC oscillator.

So there we go. The chips is expecting an external oscillator. All we need to do is give it one, and it’ll be happy as a pig in mud. The top of page 27 has the schematic and formula you need to use to design it. I simply picked a nice easy 1MHz with a 1nF cap and calculator the resistor from that R=1/(3fC) which gives 333 ohms. 370 is a nice common value that’s pretty close. Close is good enough, as we just want the darn thing to oscillate so we can swap it back to the new mode :slight_smile:

It’s not doing any pullup/smoothing action, it’s an actual oscillator that you’re designing here (well, the RC time constant part anyway, the rest of the magic is inside the mega8)

http://www.engbedded.com/cgi-bin/fc.cgi/ is a fairly good calculator if you want one.

I hope that makes it clear. Let me know if you’d like anything clarified.

Yeah, I set the 0xE6 value previously (a wacko value for ATMEGA8), when I was going through the Sparkfun tutorial, which uses the mega168 but with mega8 pictures :slight_smile: I assumed too much that things are the same between mega8 and the mega168.

And I did use the fuse calculator now successfully got my mega18 operates at 16Mhz :slight_smile:

Thanks again for your help.

I still don’t get the reason uses using the 1nFp cap and the 330 ohm resistor to bring back my ATMEGA8 to life. I understand completely of the fuse bits stuff–that’s just software configuration.

Thanks for your help! Good weekend!

I still don’t get the reason uses using the 1nFp cap and the 330 ohm resistor to bring back my ATMEGA8 to life.

an apple fell on my head…My mind was so locked into using crystal and resonator. The 1nF and the 330 ohm resistor is create an external RC oscillator close enough to the ATMEGA8 internal RC oscillator…

I saw a similar thread in another forum:

http://www.edaboard.com/viewtopic.php?t … highlight=

hope it helps.

ok this happend to me too.

atmega8

16MHz crystal with 22pf caps to ground

using an AVRISP mkII set it in AVR studio to Ext. Clock; Start-Up time: 6CK + 0ms, and also programmed CKOPT

Will the 1nF cap and vcc on xtal1 work for this too? (wait do they both go to xtal1/osc1?)

Fixing this problem requires knowing exactly what chip you’re using and what the fuse bits are set to.

If you’ve managed to set the fuse bits that tell the chip to expect an external clock signal then no, the resistor/capacitor won’t help because it’s different but still not right.

In that case you would need to supply an actual externally generated square wave clock signal. You can build one, or there are modules that will generate them for you. They’re called crystal oscillators, and are easy to find at various suppliers.

mkissin:
ok wait, I finally dug out the datasheet for the mega8 and you’ve set the fuse bits to something completely whack. Fortunately for you, it’s much easier to fix! Initially I was looking at the mega88 datasheet, but it turns out these have actually changed between the two chips.

You’ve set the clock source to an external RC oscillator, in the range 1 to 3MHz.

Just put a 1nF cap from OSC1 to ground, and a 370 ohm resistor from OSC1 to Vcc.

That should get you up and running again. Let me now if it helps.

Ok that is just cool, I’ve been though the datasheet many times and this never noticed it. Good find.

newbie123:
I saw a similar thread in another forum:

http://www.edaboard.com/viewtopic.php?t … highlight=

hope it helps.

actually it does :!: