Electronic – Troubleshooting an ATMega328p clock setting

atmegaavr

I am trying to run my ATMega at 16MHz using this crystal

I set the lfuse bit to F7 (see here)

The command I used to set the lfuse bit was

C:\>avrdude -p m328p -P lpt1 -c stk200 -U lfuse:w:0xf7:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "0xf7"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xf7:
avrdude: load data lfuse data from input file 0xf7:
avrdude: input file 0xf7 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

I had code on the chip that was blinking a LED once every second. After I set the lfuse bit it stopped.

I tried to read the lfuse bit via

C:\Documents and Settings\admin>avrdude -p m328p -P lpt1 -c stk200 -U lfuse:r:-:
h -U hfuse:r:-:h

avrdude: AVR device not responding
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

I believe I have the crystal setup correctly on pins 9 (TOSC1) & 10 (TOSC2). I am using 22 pF caps.

I am seeing 5V on pin 10 and 0V on pin 9

What steps can I take to troubleshoot this?

Best Answer

That's a really odd response you're seeing. Of course there's the obvious suggestion of: have you tried power cycling everything in the chain? (PC->STK200->devboard) But also, do you have another AVR programmer you can try? Do you have another ATmega328P you can try reading & writing? Have you ever been able to read fuse settings with any programmer?

Other things to try: Can you remove the crystal and see if you can communicate with the chip then? Does your programmer have the ability to adjust SCK speed? (the STK500 can do this, not sure about STK200) It may be the chip got in a really low speed mode.

As a last resort, you'll need to put the chip in a high-voltage programmer. I know at least the STK500 can do that, and there are a few circuits out there for hacking a HVP out of an Arduino or LPT port. I've had to resuscitate a few AVR chips that way because of an electrical glitch or I flubbed settings.