I am in the process of building out my own custom Arduino. I have the device here and am having issues getting the 16U2 USB-Serial chip to communicate with the Mega 2560 IC. I have tried the following:
Used FLIP to upload Arduino-usbserial-atmega16u2-Mega2560-Rev3 and Arduino-usbserial-mega over USB to the 16U2 successfully. I tried both.
Used ICSP to upload the bootloader from the Arduino IDE to the MEGA via another arduino as ISP.
Used ProgISP to upload stk500boot_v2_mega2560 to the mega2560 (as another method)
Successfully uploaded a modified "blink" that also prints a string to the serial port through ICSP. I can tell it works as both pin 13 LED and RX flash as they ought to.
However, when I open the serial port, the data comes through corrupted, as if I were on an incorrect baud rate. I also cannot upload a sketch using the 16U2 like I would typically do for the arduino.
Additionally, when I try to upload a program, I get a timeout communicating with programmer error.
If I merge TX and RX (the pins coming from the 2560) and send a string over the serial port through the 16U2, it repeats back to me as expected, which leads me to believe there is something going on with the 2560 itself. Does anyone have any suggestions I could try?
UPDATE:
After reading through This Post, I am considering whether the issue I am seeing has to do with the fuse bits on the ATmega16u2. I am struggling to find steps to set these. I found This Video and have ordered an USBTiny ISP programmer and will attempt to follow these steps to set the fuse bits. Any other advice is well welcome!
Notes:
Change "-cusbasp" to match your ISP device.
If your board has the older ATmega8u2, use "-pm8u2" instead of "-pm16u2"
Change Directory to the Arduino "hardware" directory.
On Windows it is something like:
`cd "C:\Program Files (x86)\arduino-1.6.13\hardware\"`
On a Mac it is something like:
`cd "/Applications/Arduino.app/Contents/Java/hardware/"`
(Use Control-Click on the app and select "Show Package Contents" to see 'Contents')
// MEGA update 16u2
tools/avr/bin/avrdude -Ctools/avr/etc/avrdude.conf -pm16u2 -Pusb -cusbasp -Uflash:w:arduino/firmwares/atmegaxxu2/arduino-usbdfu/MEGA-dfu_and_usbserial_combined.hex -Ulfuse:w:0xFF:m -Uhfuse:w:0xD9:m -Uefuse:w:0xF4:m -Ulock:w:0x0F:m
For the MEGA, connect an ISP.
Select Tools -> Board -> Arduino MEGA
Select the ISP with Tools -> Programmer.
Select Tools -> Burn Bootloader
That will clear the chip, set the fuses, and upload the bootloader.