Atmega328p won't program on custom PCB

Hello,

I have a prototype PCB which is essentially exactly the same as the schematic for an Arduino Mini Pro (I am using two 22pF decoupling capacitors and a 16MHz external crystal, there is no LED on pin 13 or swtich on reset, but all the 0.1uF decoupling capacitors are in place on VCC and AREF).

I have everything connected as in the below schematic:

I have uploaded Nick Gammon's bootloader to my Arduino Mega, and it successfully connects to the Atmega328p on my own PCB and takes the bootloader no problem. (I chose the 16Mhz option).

I then upload the ArduinoISP sketch to my Arduino Mega (under Files -> Examples -> ArduinoISP), again no problems here.

However, I cannot get the Atmega328p to take a sketch. I have selected the Arduino Mini Pro as the Board (as mine is the same schematic) and the processor as 5v 16Mhz, and selected my Arduino Mega as the port, and "Arduino as ISP" as the programmer. I then hit Sketch -> Upload using programmer, and all I get is the following:

"C:\Users\nb\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino12/bin/avrdude -CC:\Users\nb\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino12/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM3 -b19200 -Uflash:w:C:\Users\nb\AppData\Local\Temp\arduino_build_437894/sketch_mar28a.ino.hex:i

avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Users\nb\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino12/etc/avrdude.conf"

Using Port : COM3
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 MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 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: stk500_initialize(): n_extparms 6 mayor 1 minor 18
avrdude: stk500_initialize(): n_extparms = 6
avrdude: sending extparam for arduino multi isp
avrdude: stk500_set_extended_parms(): can't get into sync
avrdude: stk500_initialize(): failed
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=0x12

avrdude done. Thank you.

the selected serial port
does not exist or your board is not connected"

Any ideas on what is going wrong?

Thank you in advance for any advice!

You have installed a bootloader onto your new clone of the Mini Pro and you want to then load a sketch via that bootloader ?

If so, installing the bootloader should have set the fuses correctly for 16Mhz with external crystal.

If you are loading a sketch to processor which has an installed bootloader, then normally you use a USBTTL adapter and the sketch is loaded via the serial port D0 and D1

Try disabling reset on the mega with 10uF cap between reset and ground after uploading Arduino as ISP to it.

The fact that the same mega with same connections works for nick's board programmer implies that the connections are fine; but the issue with needing to disable autoreset does impact some people (for reasons unclear, not everyone).

(deleted)

Unfortunately there is a bug with the avrdude 6.3.0-arduino12 included with the Arduino AVR Boards 1.6.20x beta package that causes this error when you try to use an Arduino as ISP:

The solution is to downgrade to Arduino AVR Boards 1.6.21:

  • Tools > Board > Boards Manager
  • Wait for download to finish.
  • Click on “Arduino AVR Boards”.
  • From the dropdown version menu, select “1.6.21”.
  • Click “Install”.
  • Wait for installation to finish.
  • Click “Close”.

pert:
Unfortunately there is a bug with the avrdude 6.3.0-arduino12 included with the Arduino AVR Boards 1.6.20x beta package that causes this error when you try to use an Arduino as ISP:
https://github.com/arduino/avrdude-build-script/issues/11
The solution is to downgrade to Arduino AVR Boards 1.6.21:

  • Tools > Board > Boards Manager
  • Wait for download to finish.
  • Click on "Arduino AVR Boards".
  • From the dropdown version menu, select "1.6.21".
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".

You absolute legend! I've spent about three evenings getting nowhere with this, I have just done as you said and bingo, away it goes.

Thank you to everyone who replied. Your kind time and attention is much appreciated.