0

First I need to say, I'm a complete electrics newbie, so I need your help.

I have got a standalone Atmega 2560, which I want to program. I connected MISO, MOSI, SCK, RESET, 5V and GND to an Arduino Uno. In addition a 16MHZ oscillator is connected to XTAL1 and XTAL2 plus I pull all VINs of the Atmega with a 100nF to GND. Plus I connected a separate VIN and GND to the 2560.

I programmed the Arduino Uno as an "Arduino as ISP". Afterwards I connected the 2560 as mentioned above, changed the board to "Mega 2560" and tried to upload a sketch through the Arduino and I get the error message: avrdude: stk500v2_getsync(): timeout communicating with programmer

Is there something I missed?

Cheers jb

9
  • Did you connect nRESET to the nRESET of the Uno? Jul 10, 2015 at 19:00
  • Yes, the Pin10 of the Uno is connected to RESET of the 2560 as decribed here: arduino.cc/en/Tutorial/ArduinoISP
    – jblaze
    Jul 10, 2015 at 19:19
  • A 16Mhz crystal needs some caps to. Also if the ATMega2560 is brand new, the fuses don't have the correct value yet. Most notably, it's set to run at 1Mhz. You have to run avrdude at a lower speed (-B10) to program the new fuses
    – Gerben
    Jul 10, 2015 at 19:19
  • What do you mean by "caps"? I have got an resistor of 1MOhm between both pins of the crystal.Yes the Atmega2560 is fresh out of the box. What fuses do I need to set?
    – jblaze
    Jul 10, 2015 at 19:19
  • I see, I don't have capacitors at the crystal (like the arduino mega 2560 R3 reference design). Could that be the cause it, doesn't work? @Gerben
    – jblaze
    Jul 10, 2015 at 19:51

1 Answer 1

0

I have a sketch that programs bootloaders. A side-effect of that sketch is it fixes up the "divide clock by 8" fuse.

It looks like the wiring will be the same, but cross-check on that page (scroll down to the part about programming the Mega2560).

Once a bootloader is installed you could use it, if you get an FTDI cable, or simply go back to using the ArduinoISP now that the fuse is fixed.

5
  • Thanks @Nick I was able to burn the bootloader to my 2560 with "Atmega_Board_Programmer": Erasing chip . Writing bootloader . ... Written. Verifying. No errors found. Writing fuses. LFuse = 0xFF HFuse = 0xD8 EFuse = 0xFD Lock byte = 0xEF Clock calibration = 0x89 Done. Signature = 0x1E 0x98 0x01 Processor=ATmega2560 Flash memory size = 262144 bytes. LFuse = 0xFF HFuse = 0xD8 EFuse = 0xFD Lock byte = 0xEF Clock calibration = 0x89 Bootloader address = 0x3E000 Bootloader length = 7474 bytes. Look good so far, but still I got "timeout" when uploading my own sketch. Did I miss something?
    – jblaze
    Jul 11, 2015 at 12:04
  • So far, so good. The chip is alive. :) Please describe your wiring for uploading your own sketch. I'm not totally sure that ArduinoISP supports the Mega2560 - it may do. Alternatives are cheap ISP programmers from eBay and other suppliers (like Adafruit or Sparkfun), get an FTDI cable and use that for serial programming using the bootloader, or use my sketch "Hex uploader" that uploads from an SD card. You need an SD card adapter for that, but they are around $15.
    – Nick Gammon
    Jul 11, 2015 at 21:43
  • Yes I think so. My wires are: MISO-MISO, SCK-SCK, MOSI-MOSI, 5V, GND, and Pin10 Uno to Reset in Mega. // Tthe fuses should be OK with your sketch "Atmega_Board_Programmer"? I have this crystal (3 leg) with a 1MOhm resistor between both legs connected to XTAL1 and XTAL2: CSTCE16M0V53-R0. The middle leg is connected to GND. // Thanks for the hint with the programmer. I will search for one.
    – jblaze
    Jul 12, 2015 at 8:08
  • I was able to write my sketch to the Atmega2560 with a USBasp. But somehow the program does not work. Simple example: I have a small LED connected to Pin D2 (thats PE4 on Atmega2560). But when I do "digitalWrite(2, HIGH);" it is not working (it has been initialized before with "pinMode(2, OUTPUT);"). Anything I need to change in my sketch? Or do I need to change fuses?
    – jblaze
    Jul 13, 2015 at 6:06
  • I think you should start a new question now. You can upload sketches so this particular one is dealt with. As to why it doesn't "work" please make a post describing your setup, post the sketch, show your wiring, etc.
    – Nick Gammon
    Jul 13, 2015 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.