Arduino UNO as ISP doesn't work

I'm trying to use Arduino UNO R3 (which is with atmega328p-pu) as ISP to program atmega328p-pu, but I can't get it to work for some reason... Could someone help me please?
I will explain everything I tried in detail so this will be LONG... (Keep in mind that I'm new to microcontrollers, I don't have any AVR programmer, all I have is arduino)

1)I googled for hours to find a solution before posting this
2)I'm completely sure the chip is atmega328p-pu, I bought it from a local store which is a Farnell distributor
(this is the chip I bought ) so it should be with default settings which means I need to burn the arduino bootloader
3)I use arduino IDE v1.0.1
4)I've set Tools>Programmer>Arduino as ISP and Tools>Board>Arduino Uno
5)I tripple checked all the connections everytime I changed something

Here is what I've tried so far:

1)Upload the ArduinoISP sketch, connected the Arduino like this + 10uF capacitor connected
to reset and ground, the crystal is 16MHz (I also didn't have 10k resistor so I used two 5.1k in series) and I was getting "invalid device signature" error
2)I connected AREF (pin 21 on the chip) to the VCC (5V), still same error
3)I powered the chip with external power supply at 5V, but without common ground with the arduino, at first I got "invalid device signature", I tried to burn the bootloader again and then this error occured:
avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51
4)I read somewhere that the capacitor is not needed so I removed it and tried again aand same as before, at first try
"invalid device signature" error, at second try the stk500 error
5)I tried all the steps from the beginning but I left AREF unconnected, didn't seem to have any difference
6)I uploaded Blink program to the arduino to make sure it still works and I haven't bricked it or something :smiley:
7)I uploaded the ArduinoISP sketch, connected the chip like this but with external power supply, no 10uF capacitor,AREF unconnected and without common ground, and tried to UPLOAD to the chip the blink program (LED connected to digital pin 9) and no luck, "invalid device signature" error again
8)I connected a common ground (ground of the supply to the ground of the arduino) and tried again to upload blink to the chip and... it WORKED!! but... the LED was blinking very SLOW, I had to change delay(1000) to delay(100) so it could stay on for around 1 sec... I thought maybe it's becouse I haven't burned the bootloader yet or something else
9)Disconected the LED, and tried to burn the bootloader, again at first signature error, after that stk500 error
10)Added the capacitor between reset and ground, at first stk500 error, at second try "avrdude: stk500_getsync(): not in sync: resp=0x00"
11)Removed commmon ground, "avrdude: stk500_cmd(): programmer is out of sync"
12)Removed capacitor and returned the common ground to see if I can still upload code to the chip, aaand at first stk500 error, at second try "avrdude: stk500_getsync(): not in sync: resp=0x00" , I still can't make it work again...
13)I tried adding the pullup resistor, the crystial with the capacitors, the 10uF capacitor, AREF, common ground, all possible combinations with these, and I keep getting one of these three errors (signature, stk500, and not in sync)
14)I tried using the code I found in this forum and connected digital pin 3 to XTAL1, but without any luck, I tried the code with almost all possible connections of the chip, no luck again
15)I'm out of ideas

Try Nick Gammon's bootloader sketch instead.
Setup the to-be-programmed part like it was a bare-minimum board:
crystal, two 22 pF caps, 10K reset resistor, 0.1uF caps on Vcc, AVCC.

Didn't work , "avrdude: stk500_getsync(): not in sync: resp=0x00"
In Gammon's site I found a board detector sketch, I tried it with crystal, without crystal and with the 8MHz clock from digital pin 9, but it doesn't detect the chip , only "Atmega chip detector." shows up in Serial Monitor.

Hi

Just this minute doing the same thing with some Farnell sourced ATmega 328. They should not require a crystal initially as they are configured to use their internal oscillator being virgin chips. However if you have managed to upload a sketch then I suspect the internal clock is now disabled and it will need a clock source.

I've been through a bit of this pain myself but seem to have things running now.
Double check your power connections are pinned into the right places on the Uno and the breadboard and other pins are two, it is easy to be one off on the Uno I find. Also make sure the chip is pushed fully into the breadboard, I tried not doing this as they are a pain to remove but connections were not reliably made.

Following the instructions at Gammons website and getting the chip detection to return something is the way to go and the first step, as if the chip detection doesn't work then programming will not either. Just go for adding a crystal and the caps, even if the ATMega is configured to use an internal clock that crystal will not stop it from entering bootloader mode.

Also after some problems here I found things magically started working after I added a 100uf electrolyte capacitor to the plus/minus rail.

If the board detection program doesn't work then bootloading will not either.

I couldn't get Gammons bootloading to work however, not sure why, it went through the process but wouldn't upload a sketch after. In the end I used the Example Ardunio as ISP sketch to the Uno, then uploaded the bootloader from the IDE.

Note, I'm not sure but I think bootloading needs to be done twice, can do no harm. First of all on a virgin chip, the fuses are set from using the internal clock to an external 16MHz crystal (usually what we use), I think it then reboots the chip before adding the bootloader, but now if a crystal isn't added the chip doesn't start back up, and the process looks finished but isn't or gives rise to errors. So I always add the crystal and caps then bootloader it again, before attempting to upload sketches.

Best of luck.

Regards

Phil

I found the problem...The pins of the chip don't make good contact with the breadboard although it was pushed all the way down... It was tricky but everything is ok now,I already burned second chip.Thank you for your help.

You can also just remove the chip from the UNO and put the new one in it to upload :wink:

Maybe change the title of the post, add "It was my setup".

JC_Maxwell:
I found the problem...The pins of the chip don't make good contact with the breadboard although it was pushed all the way down... It was tricky but everything is ok now,I already burned second chip.Thank you for your help.

Did you get it to work with the Gammon setup, or with your OP setup? I am starting to head down this path and am doing research before sourcing parts.
Thanks!

The essayist way to program those is to swap chips its super easy and you load it just like the uno then take it out pop it in your project and done :slight_smile:

drksam:
The essayist way to program those is to swap chips its super easy and you load it just like the uno then take it out pop it in your project and done :slight_smile:

I like the sounds of this method. Once flashed with the bootloader and your sketch, will it then require an external oscillator or will the internal be used? If internal, does it require calibration? I'm trying to time some blinky project pretty specifically, and it didn't work out for me so well with the ATTiny85 as the internal oscillator required calibration, which apparently is not something I'm capable of.

benmctee:

drksam:
The essayist way to program those is to swap chips its super easy and you load it just like the uno then take it out pop it in your project and done :slight_smile:

I like the sounds of this method. Once flashed with the bootloader and your sketch, will it then require an external oscillator or will the internal be used?

It will require an external crystal or ceramic resonator as when the bootloader is burned into the chip it also burns the fuse bytes which set up what clock source to use.

If internal, does it require calibration? I'm trying to time some blinky project pretty specifically, and it didn't work out for me so well with the ATTiny85 as the internal oscillator required calibration, which apparently is not something I'm capable of.

I beleave that you can turn on the internal some where in software but iv never tried to do it. It easy to use the 16mhz external and they don't cost much.

Awesome, thanks for your advice!

Did you get it to work with the Gammon setup, or with your OP setup? I am starting to head down this path and am doing research before sourcing parts.
Thanks!

I got it to work with OP setup.

P.S. I also posted this this topic at http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=1169668
It might be of some help to someone.