Custom board Inspired by Arduino Mega2560 - having serial communications issues.

I designed and fabricated a custom board that was inspired by the Arduino Mega 2560 R3 (atmega2560 MC and atmega 16u2 Usb to Serial Chip).

Currently I have proven out all features of the board except the serial communication between the Microcontroller and My computer.

Here is the situation:

  1. I can use Arduino to compile a hex file from my sketch file and output it to a temporary folder on my computer. I can then upload this file directly to the atmega 2560 using the ICSP Header Pins, an AVRISP MKii programmer, and atmel Studio. This has allowed me to vet out all of the various IO on the board.
  2. However, I cannot upload the sketch/program through the actual Arduino IDE. When I try to upload it directly through arduino and the USBto Serial Chip I receive the following error:

Using Port : \.\COM9
Using Programmer : stk500v2
Overriding Baud Rate : 115200
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: Recv:
avrdude: stk500v2_ReceiveMessage(): timeout

  1. I have done the loop-back test to verify that the, the USB cable, Chip Driver, Firmware and USB to serial Chip is working properly. Any command that I send through the Arduino serial monitors returns the same message.
  2. Additionally, I have actually uploaded a simple serial output program directly to the microcontroller (using the ICSP pins and atmel Studio). It reads an analog voltage value and outputs it to the TX/RX lines. This data is then passed through the UsbtoSerial Chip and onto my computer. However! When i try to view this data, it appears to be corrupted. I receive the data! but it is not readable. If the MC sends a single line, I receive a single Line. If the MC sends a series of data sets, I receive a series of Data sets.
  3. I have tested the baudrate as potential issue extensively but it doesn't seem to be the issue.
  4. I have tested the fuses and lock bits when programming the MC but that doesn't seem to be the issue either.

In summary, it seems the Atmega 2560 and the Atmega 16u2 are communicating with each other but they dont seem to be speaking the same "language" or at the same rate. There is some type of serial communication issue that I am missing here.

Does anyone have any thoughts?

Check and make sure you are running the Mega2560 clock at 16MHz otherwise it will cause baud rate issues with the default libraries.

What bootloader are you using for the Mega2560? Keep in mind if you program the sketch directly via ICSP, then you are probably overwriting the bootloader.

Using Programmer : stk500v2

Try to change stk500v2 with wiring

For example for Atmel Studio 6 with arduino mega2560 :

(xxxxxxxxxxx\hardware\tools\avr\bin\avrdude.exe -Cxxxxxxxx\avrdude.conf -v -v -v -v -patmega2560 -cwiring -P\.\COM3 -b115200 -F -V -D -Uflash:w:"$(ProjectDir)Debug$(ItemFileName).hex":i)