Arduino ISP was working, not not

Hello all,

I set up a Duemilanove as an Arduino ISP, and was using it to program another ATMega328 on a breadboard while I prototyped a project. I set the fuses on the breadboard ATMega to use the internal oscilator (-U lfuse:w:0xf2:m) using my Arduino ISP. Everything worked great, I finished the project, which was a gift, and gave it away. Now I’m trying to get another ATMega328 set up the same was, and I’m having no luck at all. I’ve checked and double checked all the connections, but all I get is error messages.
If I use the Arduino IDE to “upload using programmer” I get this:

Binary sketch size: 4812 bytes (of a 32256 byte maximum)
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

To narrow things down, I tried using avrdude on the command line with that -F, to see if I can read a fuse:

avrdude -PCOM10 -pm328p -cstk500v1 -b19200 -v -U lfuse:r: -F
avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"


         Using Port                    : COM10
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  36
00 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  45
00 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0
 0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0
 0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.15s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading lfuse memory:

Reading | ################################################## | 100% 0.07s

avrdude: writing output file ""
avrdude: error opening : Invalid argument
avrdude: output file  auto detected as invalid format
avrdude: can't open output file : Invalid argument
avrdude: write to file '' failed

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

The bit that’s concerning me is “avrdude: Device signature = 0x000000”. I get the same output if I don’t even have a chip to read from plugged into the breadboard.
I’ve used a multimeter to confirm that the D11-13 pins are connected between the two chips (with the probes directly on the leads of the chips) and that D10 from the ATMega on the Duemilanove is connected to reset on the chip I’m programming.
I have the three status LEDs hooked up to the Duemilanove, and when I reset the board, the “programming” LED flashes a few times, then the “error” one flashes a few times, and then the “heartbeat” one sits and pulses. When I run avrdude, the “programming” one goes solid for a second or so. All the bits about the LEDs behave the same whether I have a chip on the breadboard or not.
That’s powering the breadboard from the GND/5V headers on the Duemilanove. When I check the voltage at the pins of the ATMega on the breadboard, it’s at 4.85V. If I also hook the breadboard up to my bench supply, I get 5.06V at the ATMega on the breadboard, but none of the other results/output changes.
I’ve tried using an ATMega from my Uno board on the breadboard, and I’ve tried with a brand new ATMega328, but I get the same results.
I’ve verified that the ATMega from my Uno is good, by putting it in the Uno and uploading the “blink” example sketch. Everything seems to work fine there, but when I move it to the breadboard, avrdude can’t seem to read it at all.
I’m completely at a loss as to what could be wrong.
I’ve attached photos of how everything is hooked up.

6777770115_69718cd493_z.jpg

6777771827_77bfa8cb72_z.jpg

6777773575_0c5b550194_z.jpg

6777775225_bcc4b78623_z.jpg

Where's the quartz / resonator ?

Uhm… … in a bag on my shelf? :*

I totally forgot that when I burned the fuse (to use the internal oscillator) on my original ATMega, I did it while it was still in the Uno board. I’d like to be able to do that on a breadboard though.

I’ve tried hooking the crystal up two different ways now, and I’m still not getting any results.
I put the crystal in the breadboard on the two crystal pins, didn’t put any capacitors in yet, and hooked my scope up to the two crystal pins. I’m getting a 16mhz wave on both channels, one that goes from 180mv - 960mv, and the other -20mv - 860mv. When I put a 10pf capacitor from each pin to ground, it changes them to 220mv - 920mv and 20mv - 820mv. Neither setup seems to make the chip run the blink sketch, or make avrdude work. Am I doing something wrong with the crystal?
I’ve attached a screenshot from the scope, and a photo of how my crystal is hooked up.

6778347517_781fc575a1_z.jpg

Most likely too late but you're going to kick yourself - you're connected to the wrong pins!

You need pins 17-19 of your '328 - you are connected to pins 16-18!

Ardu' pin 13 is '328 pin 19 Ardu' pin 12 is '328 pin 18 Ardu pin 11 is '328 pin 17

8)

Ugi

PS previous photos - where you didn't have the crystal - you were connected to the right pins!

Whoops, I should have posted a followup sooner.

I did eventually discover that myself, however, it didn't change anything. I still get the same errors and such when trying to use avrdude, and the chip still won't run the blink sketch, so I must have something else wrong still. The only thing I can think of is that 10pf capacitors aren't the right size for the crystal.

See other threads, but the AISP with 1.0 isn't quite right.. (downgrade arduino or bother coding badly to send you his tinyisp)

Technically it should be 18 - 22 pf (and I also think the decoupling cap in the foreground is the wrong way around - long lead should be to +ve) but it seemed pretty unlikely that this would be the cause of the error.

I always seem to get something wrong when I use Arduino ISP to a breadboard but it's nearly always something obvious - first time it was no power. Another time it was using the wrong pin for controlling re-set. Then it was forgetting to disable auto-reset on the programmer board.

Actually, that's a point - do you have the necessary 110R resistor from reset to +5v on your Duem' to disable auto-reset ?

Edit - from the picture it doesn't look like you were using a resistor to disable auto-reset. Unless you have cut the trace for that, you may find that is the cause of your trouble - see http://www.arduino.cc/playground/Code/MegaISP

Thanks for the comments Dr_Ugi and remiss. I was using the Arduino 1.0 AISP without too much problem previously, programming an ATMega that I had already set the fuses on to use the internal oscillator. Do you know what specifically is wrong with the AISP in 1.0? I did a forum search, but I guess my search mojo isn't good enough, I couldn't find any references.

Thanks for pointing out that I hadn't disabled auto-reset. That explains one of the problems I was having. I was hitting reset on the Duem every time just before running avrdude. I had to get the timing just right for programming to work. It sounds like that problem should go away if I disable auto-reset with a resistor, like you mentioned.

I'll pick up some more capacitors this weekend and see if it makes any difference.

It also looks to me (from my photos, I'm not at home) like I have both decoupling caps connected wrong. Wow.

I really don’t remember what happened to me, but I think I got arduino isp 1.0 to give me device signature. However couldn’t upload more than ~94% so you might run in to that issue or any of the others mentioned here:

http://arduino.cc/forum/index.php/topic,82451.html

Oh, I see. I'm using a Duem as the programmer, and I uploaded the AISP sketch to it using 1.0, and haven't been having that problem. Maybe it's specific to Arduino 1.0 and an Uno.

Either way, I'm certainly looking forward to trying some of these suggestions on Saturday. I have a few contraptions I want to build with an AVR wired up "dead bug" style for compactness, and I'd like to have the option of using a crystal for it still, instead of having to run at 8Mhz.

Thanks again for the help and suggestions. :)

Thanks everyone for all your help. I just managed to get it working. XD

The original problem was that I was trying to program a chip with no crystal attached, and without the fuses set to use the internal oscillator. When I tried to hook up a crystal, I did it with what capacitors I had, so I used 10pf capacitors. That seems to have been the problem. Replacing them with 15pf or 20pf capacitors (didn't try any higher than that) makes the blink sketch run now.

The 2nd problem was that during all my debugging, I had disconnected and reconnected the connections to the Duem' that was doing the programming. When I reconnected them I made an "off by one error" on which pins I hooked up. However, with the crystal not working, it wouldn't even run the blink sketck, so I wasn't trying to program it at that point.

The 3rd problem was that I hadn't used a resistor to short the Duem's reset to +5v, so I was having to time things carefully and reset it shortly before avrdude ran. With the resistor there now, programming Just Works.

The 4th (yeah, I'm feeling stupid now) problem, though I don't know if it was actually causing a problem, was that I had both decoupling capacitors hooked up wrong. One was backwards, and the other was between GND and AREF instead of VCC. Because I have AREF and VCC both connected to the +5v rail on my breadboard, that one was probably actually doing it's job fine, but it was still wrong. :cold_sweat:

Thanks again for all the help. :) I would have never figured this all out on my own.