I essentially built my own ATMega2560 board with a blank ATMEGA2560-16AUR as the MCU and a blank ATMEGA16U2-MUR as the USB-MCU interface.
I managed to upload the bootloader onto the MCU using an UNO as an ISP. This worked well. I am able to upload code onto the MCU as long as I keep the UNO connected to the MCU's SPI ports and "Upload as Programmer".
What I would like to do is remove the UNO as an ISP and use the ATMEGA16U2 to upload code. From what I understand, I would need to upload firmware onto the ATMEGA16U2? I would like verification that this is the correct step to take. In addition, if anyone knows of any tutorials that explain how to do this? I've been looking online and I cannot find one for the AtMega2560 board - the only ones I've found are for the UNO.
I used the following link to upload firmware oto the MEGA16U; however, I am getting timeout errors when trying to upload a sketch using the MEGA16U.
Link: Projects from Tech: Updating Firmware on ATmega16U2
There should be no difference between setting up the ATmega16U2 for Uno or Mega.
Note that when you do a Sketch > Upload Using Programmer, the bootloader is erased. So you need to do another Tools > Burn Bootloader before you can upload to your ATmega2560 using the ATmega16U2.
pert:
There should be no difference between setting up the ATmega16U2 for Uno or Mega.
Note that when you do a Sketch > Upload Using Programmer, the bootloader is erased. So you need to do another Tools > Burn Bootloader before you can upload to your ATmega2560 using the ATmega16U2.
Hey Pert,
I did what you said.
I burned the bootloader using my Arduino as an ISP to ensure that my bootloader was on the MCU.
Then I flashed to my ATMEGA16U with "Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex" and tried to upload code using it. I get timeout errors though.
I am using the same process when uploading sketches vs burning bootloader. I connect my Arduino as an ISP to my MCU's SPI ports. If it is able to upload sketches properly, should it not be able to upload bootloader properly? Do I need to add any decoupling capacitors to my MCU to burn the bootloader? Please note that my target is a bare bones ATMEGA2560 and my ISP is an Arduino UNO with ArduinoISP sketch uploaded onto it.
Budvar10:
Sorry, I'm lost. In 1st post you wrote that you are able to burn the bootloader to ATmega2560. Yes/No?
Sorry if I confused you. What I meant was, after I connected my Arduino as an ISP to my MCU, I did two things:
I burned the bootloader and the compiler said it uploaded correctly
I uploaded a sketch through the Arduino as an ISP and ran the board, proving that the sketch uploaded properly.
I had no way of "proving" that the bootloader uploaded correctly. Since I was able to prove that the sketch uploaded properly, and I used the same method to upload the bootloader, I assumed that the bootloader uploaded properly.
Now, I flashed code onto my MEGA16U and did the loop back test to prove that the MEGA16U has the correctly firmware. Then, I burned the bootloader again onto my MCU. I tried to upload a sketch via MEGA16U. This yielded a timeout error.
From these list of steps, I can only assume that the issue is with uploading the bootloader.
Budvar10:
It is good to have. According my personal experience it works without but... you have a problem, right? It is strongly recommended.
I have added a picture of the schematic in the first post. If you look at my schematic, you will notice that I have a 0.1uF capacitor between Vcc to COM, as well as Aref to COM.
Now, I flashed code onto my MEGA16U and did the loop back test to prove that the MEGA16U has the correctly firmware. Then, I burned the bootloader again onto my MCU. I tried to upload a sketch via MEGA16U. This yielded a timeout error.
Try removing the C38 capacitor from the Reset lead.
I have used some minimum system Boards using ZIF sockets that had .1uF capicators from reset to ground and the DTR lead would not reset the chip when using USB serial ftdi boards.
Removing the capacitor or using a 10uF capacitor on the DTR lead would usually work.
Can you explain the C38? This cap can cause problems with reset signal. As @kprims wrote, remove it.
R116 can cause problems with oscillator. Normally, no resistor is needed.
Finally, you are missing decoupling. It is recommended to have 100nF caps at each VCC pin as close as possible.
Budvar10:
Can you explain the C38? This cap can cause problems with reset signal. As @kprims wrote, remove it.
R116 can cause problems with oscillator. Normally, no resistor is needed.
Finally, you are missing decoupling. It is recommended to have 100nF caps at each VCC pin as close as possible.
Hello,
I will retry after removing C38.
I believe if you look at the datasheet for the MCU, it recommends putting a resistor there; I will double check to verify.
Finally, there are decoupling capacitors of 0.1uF from Vcc to COM, but I seem to have cropped it out by accident.
I believe if you look at the datasheet for the MCU, it recommends putting a resistor there; I will double check to verify.
No, there is without: Figure 10-2. Crystal Oscillator Connections. Genuine Arduino uses 1M. It is some kind of dumping for over-shots on edges. However, it is good to check it with oscilloscope and in situation when something does not work as expected, it is good to avoid of any potential problem.
In your MCU_modified image, what exactly did you modify?
Moreover, I only raise this question because it's not making sense to me but ..
How am I able to upload a program through my "Arduino as an ISP", but not able to burn the bootloader? At the end up of the day, they're both using generally the same process to upload code onto my bareboard.
P.S: Changing that capacitor has not helped, so I am not sure what the problem is