Arduino as ISP will not erase or program the ATMEG8A target

I"m new to using the Arduino. I'm trying to use my Arduino Uno as an ICSP programmer. I loaded up the Arduino as ISP sketch, and have been struggling to get it to program the target. I'm using avrdude, with the following command,"avrdude -e -v -F -pm8 -carduino -P COM3 -D -b19200 -Uflash:w:"C:\BLHeli-master\BLHeli-master\Atmel\Hex files\myfile.hex":i -C"C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"
" , executing avrdude from within Atmel Studio 7. And, the target is an ATMega8A.

With the baud rate 19200, the programmer does not respond, even though I verified that the #define in the sketch as set correctly:

// Configure the baud rate:

#define BAUDRATE	19200
//#define BAUDRATE	115200
// #define BAUDRATE	1000000

.

This the error I see:
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"

  • Using Port : COM3*
  • Using Programmer : arduino*
  • Overriding Baud Rate : 19200*
    avrdude.exe: stk500_recv(): programmer is not responding
    avrdude.exe: stk500_getsync() attempt 1 of 10: not in sync: resp=0x52
    avrdude.exe: stk500_recv(): programmer is not responding
    avrdude.exe: stk500_getsync() attempt 2 of 10: not in sync: resp=0x52
    avrdude.exe: stk500_recv(): programmer is not responding
    avrdude.exe: stk500_getsync() attempt 3 of 10: not in sync: resp=0x52
    avrdude.exe: stk500_recv(): programmer is not responding
    avrdude.exe: stk500_getsync() attempt 4 of 10: not in sync: resp=0x52

until it totally times out.

If I don't include the "-b 19200" option in the avrdude command, I get past this, and it looks like the programming worked, except that it then fails verification.

I read out the chip, and indeed, the contents were nothing like the hex file I programmed it with.

I then tried just erasing the chip, and reading it back. Again, I expected to see all 0xFF s , but again saw [garbage] data in the device.

I don't know what else to do.

  1. does a chip erase disable any preset fuses? Am I struggling because the chip is in some sort of write protect mode? If chip erase doesn't free the chip up to be reused, what does?

  2. Is it possible I'm not talking to the target, but instead to the 328 on the UNO?

  3. What else can I try?

Thanks in advance for any pointers.

Do you have a 10 uF capacitor connected between the reset and ground pins on the Uno you're using as an Arduino as ISP?

ywu:
2) Is it possible I'm not talking to the target, but instead to the 328 on the UNO?

Yes, this is why the capacitor is needed to disable the auto-reset circuit. If the Uno gets reset during the programming process, then the programming process will attempt to act on the Uno, rather than acting through the Uno on the ATmega8A target.

how critical is this cap value? I tried a 100uF (what I could find quickly), and I got the same behavior --fails to verify:
avrdude.exe: verifying ...
avrdude.exe: verification error, first mismatch at byte 0x0000
0x00 != 0xb6
avrdude.exe: verification error; content mismatch

avrdude.exe: safemode: lfuse reads as 0
avrdude.exe: safemode: hfuse reads as 0
avrdude.exe: safemode: lfuse reads as 0
avrdude.exe: safemode: hfuse reads as 0
avrdude.exe: safemode: Sorry, reading back fuses was unreliable. I have given up and exited programming
mode

avrdude.exe done. Thank you.

I put a scope probe on the the reset line and it is high the whole time....I thought I'd see it go low at the beginning of the programming cycle to put the target in serial programming mode. Btw2, not sure how this would work, since it is shared between the reset on the ICSP and the reset line to the ATMEGA328 on the Arduino.

ywu:
Btw2, not sure how this would work, since it is shared between the reset on the ICSP and the reset line to the ATMEGA328 on the Arduino.

There's your problem. You need to connect pin 10 on the Arduino as ISP to the reset pin on the target.

So the SS pin (SPI chip select) serves as the Reset to the target for programming? Wow, this is not in any of the documentation I've read anywhere for the past 2 days!!!! We will try it right away...Thank you.

It's just an arbitrary pin. The fact that it happens to be SS on the ATmega328P is not relevant. You can modify the ArduinoISP sketch to use any pins, but 10 is good enough.

This is documented in the official Arduino as ISP tutorial:

It's also in the comments in the ArduinoISP sketch:

// Pin 10 is used to reset the target microcontroller.

I’m don’t understand how I missed this completely – but this was the issue! thank you @pert again for your help.

You're welcome. I'm glad to hear it's working now. Enjoy!
Per