0

I am working on a prototype device which I am now on my 2nd board iteration and moving away from it being a shield and wired to an arduino mega2560 board.

I have used the freely available Arduino mega 2560 schematic and incorporated this into my project.

I notice that there are 2 µcontrollers on this schematic, (Atmega2560 & Atmega16U2)

I understand that the arduino bootloader resides on the 16u2 and it connect to the usb connector. the 16u2 then programs the 2560 with the code you send it.

On the searching I have done I'm getting myself terribly confused. Someone suggested to me that I could in fact do away with the Atmega16u2 all together (this would drastically reduce my component count and free up valuable board space)

However, I was intending to flash a boot loader that would make the device appear to a computer (over usb) as a midi controller device.

I am unclear if I can indeed interface a usb port directly to the ATmega2560, and upload my sketch code AND a midi-over-usb boot loader.. I doubt the advice because the ATmega16U2 (i think) has a built in UART to communicate via usb and that the 2560 does not...

Sorry If this all sounds vague, I'm searched out and confused...

thanks.

migrated from electronics.stackexchange.com Oct 20 '15 at 22:15

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • USB really needs specialized hardware to handle the low-level signalling and timing requirements. 1.1 can be bit-banged if you have the resources (obdev.at/products/vusb/index.html for example), but anything better than that pretty much requires the dedicated hardware. A common UART won't even come close. – AaronD Oct 20 '15 at 21:49
2

I understand that the arduino bootloader resides on the 16u2 and it connect to the usb connector. the 16u2 then programs the 2560 with the code you send it.

That is a misunderstanding.

The bootloader is on the 2560. The 16U2 contains its own custom firmware which acts as a USB CDC/ACM interface to connect the USB to the 2560 as a TTL UART connection.

The same can be done using any number of other similar devices, such as the FT232R etc.

You cannot directly connect the USB to the 2560 since the 2560 has no concept of what USB is. The 16U2 has that knowledge, but doesn't have as many IO pins as the 2560, so combining the two gives you a total system that both understands USB and has lots of IO.

  • thank you for this useful reply. If I am understanding you correctly then, I could use an FT232R to give the 2560 usb communication capability, and also flash the code (in addition to my program code) to enable the device to be seen as a midi controller (HID Device) on connection to a computer? – Brad Holland Oct 21 '15 at 0:32
  • @BradHolland: No. The FT232R is strictly for serial communications. You will need to use a MCU with native USB support (such as the '16U2 on the Mega 2560). – Ignacio Vazquez-Abrams Oct 21 '15 at 3:44
1

Someone suggested to me that I could in fact do away with the Atmega16u2 all together (this would drastically reduce my component count and free up valuable board space)

I recommend that you keep the '16U2 and ditch the '2560. Since the '16U2 is both native USB capable and has sufficient I/O for a MIDI controller then you should use that one for your project.

Of course, since there's no Arduino core for the '16U2 you may want to consider either learning AVR programming without Arduino (when will there be a better time to do so?), or switching to the (overpowered) 'U4, which uses the Leonardo core.

  • thank you. This isn't just a simple midi controller I'm confident the 16u2 wont work for the application. we're already using a lot of i/o including a large array of leds, analog inputs and an oled screen.. – Brad Holland Oct 21 '15 at 0:30
  • Then you'll need to find some sort of protocol you can use to talk between the '16U2 and the '2560. – Ignacio Vazquez-Abrams Oct 24 '15 at 6:28
0

if I can indeed interface a usb port directly to the ATmega2560

You cannot interface USB directly to the ATMega2560, because that µC has no USB support build into (and VUSB is probably no solution either).

If your program is simple enough, then it could fit onto the ATMega16U2 on its own, eliminating the 2560.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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