[solved]ATMEGA2560 won't upload

Hi everyone,

I have created this PCB that uses the ATMEGA2560 and a FT232RL FTDI converter but I can’t get it to run properly. I am completely confused why it doens’t work, i hope someone is able to help me.

First I uploaded the bootloader using a USBaps programmer for which it gives no error messages and tells that the bootloader is programmed correctly so I assume it is.

As soon as i connect the device through my computer it recognizes the FT232RL and gives it a COM port (it already had the drivers installed), so I assume that works correctly as well.

When I want to upload a sketch it can’t upload and after a while it gives the error message:

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

This lead me to believe that either my RxD or TxD wasn’t connect. So i double checked with a multimeter and the connections seems solid.

I have tried uploading a test sketch with my USBaps programmer to test if the sketches came through. The sketch was a LED blink sketch (but this time with a vibration motor), the sketch says to be uploaded succesfully however the vibration motor doesn’t blink at all (I checked the connection using my multimeter and seems solid).

I have tried uploading the bootloader again multiple times, it doesn’t seem to make a difference. I am at the end of my knowledge, I hope someone can help me.

I’ve added the schematics to the attachments to see if someone can spot a mistake there (I didn’t connected the FT232RL VCC to vcc but i jumped it now so it works).

BartZuidervaart: The sketch was a LED blink sketch (but this time with a vibration motor), the sketch says to be uploaded succesfully however the vibration motor doesn't blink at all (I checked the connection using my multimeter and seems solid).

Why did you not try it with a LED and 220 Ohm resistor first?

My recommendations:

  1. Unless you have special proprietary firmware on the USBasp it won't work on an ATmega2560: https://forum.arduino.cc/index.php?topic=354831.0 So, I would recommend using another Arduino, such as an Uno or Mega2560 as an ISP programmer by loading the example ArduinoISP sketch on it and selecting from the Tools, Programmer menu "Arduino as ISP" and do not use USBasp. After uploading the ArduinoISP sketch, put a 10uF or bigger capacitor between GND and Reset on the programmer Arduino to disable auto reset. The negative or striped lead of the cap goes to GND. Guide for how to use an Arduino as ISP: https://forum.arduino.cc/index.php?topic=332536.0

  2. Do you have a 16MHz crystal on your board providing the clock to your ATmega2560? If so, you can use the Tools, Board selection "Arduino Mega or Mega 2560" to burn the bootloader.

  3. I recommend going into the IDE preferences and checkmark show verbose output during upload.

Thank you guys very much for your reply's.

Why did you not try it with a LED and 220 Ohm resistor first?

That would have been the smart thing to do, however a LED or a vibration motor shouldn't make a difference in this case.

My recommendations:

  1. Unless you have special proprietary firmware on the USBasp it won't work on an ATmega2560: https://forum.arduino.cc/index.php?topic=354831.0 So, I would recommend using another Arduino, such as an Uno or Mega2560 as an ISP programmer by loading the example ArduinoISP sketch on it and selecting from the Tools, Programmer menu "Arduino as ISP" and do not use USBasp. After uploading the ArduinoISP sketch, put a 10uF or bigger capacitor between GND and Reset on the programmer Arduino to disable auto reset. The negative or striped lead of the cap goes to GND. Guide for how to use an Arduino as ISP: https://forum.arduino.cc/index.php?topic=332536.0

  2. Do you have a 16MHz crystal on your board providing the clock to your ATmega2560? If so, you can use the Tools, Board selection "Arduino Mega or Mega 2560" to burn the bootloader.

  3. I recommend going into the IDE preferences and checkmark show verbose output during upload.

I tried bootloading it with a arduino uno as ISP, the result stays the same :(. No error messages, but the FTDI still won't connect and uploading a sketch with the programmer still does nothing even though it gives no error messages.

I have added the verbose output during the upload to this message, although I can’t see any error messages.

I noticed I misplaced my voltage regulators and removed them just in case, but the problem remains. Could a shortcut result in the same issue, shutting the ATMEGA2560 down? When I connect VCC and GND to the multimeter i can hear a beep(from the multimeter) for a fraction of a second, I assumed this is a capacitor bleeding and it couldn’t hurt.

verbose output.txt (9.47 KB)

Ok it is now bootloaded.

Do you have a 16MHz crystal on your board providing the clock to your ATmega2560?

What are your FDTI connections?

What is the verbose output you get from the FTDI upload of a sketch?

Ok it is now bootloaded.

Do you have a 16MHz crystal on your board providing the clock to your ATmega2560?

What are your FDTI connections?

What is the verbose output you get from the FTDI upload of a sketch?

I have a 16MHz crystal connected the XTAL2 and XTAL1.

My FTDI connections are:

VCCIO - VCC
VCC - VCC
USBD-  - D- (USB)
USBD+  - D+ (USB)
DTR - RESET(ATMEGA2560)
TxD - RxD(ATMEGA2560)
RxD - TxD(ATMEGA2560)
CTS - GND
AGND - GND
GND - GND
TEST - GND

(i’ve added the skematics image to this post for a better overview)

I’ve added the verbose output of uploading a sketch via the ft232rl.

verbose output ft232rl.txt (1.28 KB)

I can get it to upload a sketch using the USBasp using this post. The sketch seems to run fine, even when I connect it through the computer via the FT232RL USB. Until i open the serial monitor to check if it receives serial data.

I have a simple sketch that blinks the vibration motor and sends a simple 'hi' message every 2 seconds. The vibration motor blinks if i connect the USB via the FT232RL so the sketch works at that point. As soon as I open the serial monitor the vibration motor stops blinking and there is no message appearing in the serial monitor.

Editing the boards.txt is beyond my experience, so I hope someone else is able to help me.

I suggest study the schematic of Arduino Mega2560 and observe the auto reset circuitry and see how the connection is made from DTR to the reset pin using a capacitor, diode, resistor. Perhaps you have a problem with your auto reset circuit.

dmjlambert: I suggest study the schematic of Arduino Mega2560 and observe the auto reset circuitry and see how the connection is made from DTR to the reset pin using a capacitor, diode, resistor. Perhaps you have a problem with your auto reset circuit.

More directly: the OP has the reset of the Arduino wired directly to DTR on the FT232RL. So connecting the FT232RL to USB pulls the reset pin low and holds it there. Naturally nothing runs - the behavior will be exactly as the OP reports it.

See the Uno, Mega2560, or pretty much any 8-bit Arduino's schematic to see how the reset is handled. Hint: you will need 2 (or really 3) additional components.

D'oh, yes I wired it directly to DTR :[, I see that I need capacitor in between and preferably a pull-up resistor as well. Thank you guys very much!

However when I do this I am still unable to upload sketches via my FT232RL, I am however able to upload a sketch with my programmer and am able to read the Serial through the FT232RL only the digitalWrite functions don't seem to work any more.

I am getting there!

BartZuidervaart: D'oh, yes I wired it directly to DTR :[, I see that I need capacitor in between and preferably a pull-up resistor as well. Thank you guys very much!

However when I do this I am still unable to upload sketches via my FT232RL, I am however able to upload a sketch with my programmer and am able to read the Serial through the FT232RL only the digitalWrite functions don't seem to work any more.

I am getting there!

When you upload using an ISP programmer, you wipe out the bootloader. You need the bootloader to be able to upload over Serial. Most likely you need to re-load the bootloader (tools->burn bootloader).

BartZuidervaart: That would have been the smart thing to do, however a LED or a vibration motor shouldn't make a difference in this case.

Oh, you think so, do you?

Well then, I can't help you.

its true there can be a big difference between pager motor and led. most motors connected directly to avr pins will wreak havoc with noise and resets without precautions. using multiple i/o in parallel works better than a single pin. the best solution is a penny fet between avr and motor.

in all cases this is where one of the famous paul__b "big" supply caps can help.

When you upload using an ISP programmer, you wipe out the bootloader. You need the bootloader to be able to upload over Serial. Most likely you need to re-load the bootloader (tools->burn bootloader).

That was it! It works fine now, thank you guys so much!

What I am curious about (and it may be clarifying for anyone reading this thread later on): When burning the bootloader what did you select as cpu: "Atmega 2650" or the "Atmega 2650 (Testato ISP Version)" from post #7.

Otherwise put, are you running the bootloader with D8 or D9 as high fuse?