Programming Arduino Mega using an Arduino Mega ICSP

Hi there,

I am trying to upload a sketch onto an Arduino Mega using an Arduino Mega as the programmer. I am getting the error "avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x06". I have the following pins connected.

Programmer to Target Mega

ICSP MISO -> ICSP MISO
ICSP SCK -> ICSP SCK
Pin 10 -> ICSP RESET //I think this should be pin 10 here? I have tried pin 53 (SS) also.
ICSP VCC -> ICSP VCC
ICSP MOSI -> ICSP MOSI
ICSP GND -> ICSP GND

The procedure I have been using:

  • Select Board as MEGA 2560
  • Upload sketch to programmer MEGA board as normal
  • Select Programmer as "Arduino as ISP"
  • Select Board as MEGA 2560
  • Click "Upload using programmer"

Am I right in saying that if I upload a sketch this way, I won't need to upload the bootloader?

I've been reading up guides on how to do this but I am still getting an error.

My plan is to build a custom PCB with an Atmega 2560 with the ICSP pins so I can program directly onto the chip without the need for a USB interface.

Thanks

Jonny

jonnyl888:
Am I right in saying that if I upload a sketch this way, I won't need to upload the bootloader?

To upload code via ICSP you do not need a bootloader.
BUT by burning the bootloader also the fuses (basic configuration, like internal or external clock and so on) are set.
So you have to burn bootloader at the beginning.
But also without this step you should get connection.

  1. Select Board as MEGA 2560 and the serial port it is connected.

  2. Upload sketch "Arduino as ISP" to your "programmer" (=ATMega 2560)

  3. Write code for the target, or use a very basic example (blink).

  4. Connect "programmer" to target:

   Arduino MEGA 2560  |    Pin    |  Pin number on  
    as ISP programmer |    Name   |  target: ATMega 2560
------------------------------------------------------------
 IC-Pin 19 (SS) 53 ....... Reset .... IC-Pin 1
 IC-Pin 20 (SCK) 52 ...... SCK ...... IC-Pin 20
 IC-Pin 21 (MOSI) 51 ..... MOSI ..... IC-Pin 21
 IC-Pin 22 (MISO) 50 ..... MISO ..... IC-Pin 22          
        GND .............. GND ...... IC-Pin 11/32/62/81
        5V ............... VCC ...... IC-Pin 10/31/61/80
  1. Select Programmer as "Arduino as ISP"

  2. Click: Upload using programmer

You will need some basic parts connected:
Quartz 16 MHz
2 ceramic caps 22 nF
several ceramic caps 100nF from Vcc to GND connections

Ah I see thanks, I thought the ArduinoISP was the bootloader! I’ll give it another go.

Do you mean these caps on the schematic (attached)? So If I were to create my own PCB, I will need these on my circuit for it to be able to upload sketches?

100nF.JPG

22nF.JPG

Two 22nF are needed for the crystal but the value could be according used crystal and its capacitance. See the datasheet for ATmega2560 how to select proper value . 100nF capacitors are for MCU decoupling and should be for each VCC pin and as close to pin as possible.

jonnyl888:
Do you mean these caps on the schematic (attached)? So If I were to create my own PCB, I will need these on my circuit for it to be able to upload sketches?

Yes, these caps in the pictures.
They are needed not (only) to upload sketches but to get the ATMega 2560 to run. It is part of the "minimal basic setup" of the micro-controller.

Take a look here:
www.gammon.com.au: How to make an Arduino-compatible minimal board
www.gammon.com.au : Solving problems with uploading programs to your Arduino
www.gammon.com.au: Atmega bootloader programmer

Much of the information provided is for ATMega 328 (not for ATMega 2560) but the principles are the same.

Budvar10:
100nF capacitors are for MCU decoupling and should be for each VCC pin and as close to pin as possible.

Very important! Keeps trouble away! :slight_smile:

Thanks for the info guys, I managed to upload the sketch through ICSP. For a while I wasn't working, it would upload fine but the program wouldn't run on the Mega. Then I found this thread, of somebody doing the same thing. Had to add a new board to the boards.txt file because of a software bug on the Mega? Somehting about setting fuses.

Thanks. :slight_smile:

jonnyl888:
Had to add a new board to the boards.txt file because of a software bug on the Mega? Somehting about setting fuses.

That issue(Program doesn't run after Upload Using Programmer with USBasp (Mega2560) · Issue #246 · arduino/ArduinoCore-avr · GitHub) has been solved in Arduino IDE 1.6.10/Arduino AVR Boards 1.6.12 by updating AVRDUDE from 6.0.1 to 6.3.