MEGA16U2 vs. CH340G as USB interface for custom Arduino design..?

I'm doing my first design for my own custom Arduino circuit. I see from studying my Uno, Mega, and Nano that two different USB interface chips are used: The MEGA16U2 AND CH340G. From studying these further, it seems the former is designed as a full ISP, and the latter is simply a USB-to-serial interface.

Some questions:

What are the advantages and disadvantages of choosing either of these for a design..?

Since the MEGA16U2 and ATMEGA328P both have there own ICSP headers, is there some purpose to this..? Is there some special use or handy tricks for using them..?

Since the MEGA16U2 is an MCU of it's own, can it be programmed to operate independently of the ATMEGA328P..? Such as for watchdog functions or some other purpose..? I'm assuming the MEGA16U2 has the typical Arduino ISP sketch loaded into it, so of course if the ATMEGA328P needs to be re-programmed afterwards, the MEGA16U2 would have to be re-programmed back to the ISP sketch first. Unless of course another separate ISP is used to program the ATMEGA328P through its own ICSP port..?

Any and all knowledge, thoughts, and discussion would be appreciated. Thanks.

Yes, I've programmed the onboard 16U2, as many others have. In fact, the second ICSP is specifically for that purpose. You can find the firmware for it on the Arduino Github site.

What is this "ISP sketch" and "full ISP" that you keep talking about? The ICSP is just a bootloader interface for Atmel processors. The Arduino firmware sets the 16U2 up as a serial to USB translator.

Also please Google this, there is stuff out there. The only thing I ever used it for, was to provide a PPS timing pulse, since the crystal on the 16U2 is quartz, vs. the ceramic resonator on the UNO that makes the timing sloppy.

Big disadvantage - try and buy a CH340G. Distributors in the US do not carry them. I won't design in anything I can't buy from Digikey, Mouser, Arrow, etc.

The 16U2 is programmed separately from the '328P, 2560, etc., because each part needs it's own Reset line. Reset is held low while SCK, MISO, MOSI are applied to write/read the parts to program the Flash and fuses.

I suppose if one cared to route the 4 control signals between the 2 chips and put a Reset Select switch switch or header or similar so that Reset from the ICSP header only went to one chip, that could work. Probably not too hard on a '328P, I'm thinking way harder on a '2560 where there are a lot more signals leading away from the chip.
Easiest might be a 3-pin header, with a female jumper to select which chip was getting Reset.
Lot easier and I suspect cheaper than a little slide switch.

The 16U2 does operate independently, performing the USB/Serial function. Not all of it's IO are used, so you could have it do some other stuff too if you wanted. It is often reprogrammed to act as a Human Interface Device (HID).

"I'm assuming the MEGA16U2 has the typical Arduino ISP sketch loaded into it"
I don't think so. If you have the IDE installed on your computer, then I believe you also have the 16U2's code that you can look at to confirm. This page seems to cover it well https://www.instructables.com/id/How-to-Restore-the-Arduino-UNO-R3-ATmega16U2-Firmw/

(Max Headroom, haven't seen that image in quite a while)

Thanks guys. Ok, now that you've both asked what I meant by the ISP sketch, I thought about it and realized I may have become a bit confused on the topic. I recently watched a Youtube video that demonstrated how to use an Uno as an ISP to program a new blank '328P that's parked on a breadboard right next to it. In the Arduino IDE, click File > Examples > ArduinoISP. I was thinking that or a variation of it is what's programmed into the '16U. Btw, I have googled this topic (and many others), and the mountains of search results was just too big to handle, so I came here to ask the experts.

There are other options; do a search for Prolific or FTDI, the latter e.g. used on original Nanos and the Sparkfun RedBoard.

The 8U2 / 16U2 needs to be programmed before it will even work, the others not. So that involves another step before your product is ready (unless you buy them pre-programmed from the factory).

If you hook up an original Uno / Mega to a PC, they will identify themselves as such; I'm not sure if this is because of the VID/PID of the 8U2 / 16 U2 or that it's embedded in those chips. A CH340 can only identify itself as a serial port (it will never e.g. say "Arduino Uno" with an Uno).

Yes, I have a couple of the FTDI programmers here.

You keep using the term "ISP" which means "Internet Service Provider".

Alternately on Duck2Go, "Illinois State Police". Probably you mean "In-system programming" but that is a much less common usage. :cold_sweat:

Now you presumably are aware that the Pro Micro uses an ATmega32U4 as both the USB interface and the primary working processor. Either the 32U4 or 16U2 can do that, the former is clearly more capable.

What you need to do is to decide to what extent you want USB functionality; the mega USB chips are specifically used where you want HID or other USB functionality alternately to a plain serial interface but do simplify the design somewhat in the general case. Of course you need to use ICSP to initially program the raw chip.

If you actually do not need USB serial functionality, it makes more sense to use your FTDI adapters. The larger question is why you want to replicate the Arduino rather than using an inexpensive Nano (clone) as a "daughterboard"?

spinjector:
I'm doing my first design for my own custom Arduino circuit. I see from studying my Uno, Mega, and Nano that two different USB interface chips are used: The MEGA16U2 AND CH340G. From studying these further, it seems the former is designed as a full ISP, and the latter is simply a USB-to-serial interface.

Some questions:

What are the advantages and disadvantages of choosing either of these for a design..?

Since the MEGA16U2 and ATMEGA328P both have there own ICSP headers, is there some purpose to this..? Is there some special use or handy tricks for using them..?

Since the MEGA16U2 is an MCU of it's own, can it be programmed to operate independently of the ATMEGA328P..? Such as for watchdog functions or some other purpose..? Arduino uno datasheet I'm assuming the MEGA16U2 has the typical Arduino ISP sketch loaded into it, so of course if the ATMEGA328P needs to be re-programmed afterwards, the MEGA16U2 would have to be re-programmed back to the ISP sketch first. Unless of course another separate ISP is used to program the ATMEGA328P through its own ICSP port..?

Any and all knowledge, thoughts, and discussion would be appreciated. Thanks.

Yes, I have a couple of the FTDI programmers here.

The 16u2 has the advantage that you can re-program it to provide a different usb service other than just usb/serial.
Iirc, game controller and midi were popular.

This tends to be less important now that there are more “native usb” chips in use like the pro-micro (atmega32u4) or all of the Sam boards.

I like to use tiny little usb modules with a Ch340e chip on them. They have the usb/serial chip, usb micro-b connector, and two leds (power, traffic). Everything I need in about the same space and price that JUST a full sized USB port would have used. But they do need to come from China, which has its own problems. My favorite supplier seems to have changed their shipping structure so now everythg cost $50+ to ship... grr.

Paul__B:
Now you presumably are aware that the Pro Micro uses an ATmega32U4 as both the USB interface and the primary working processor. Either the 32U4 or 16U2 can do that, the former is clearly more capable.

Paul_B, clearly I haven't been paying attention, because I was not aware of either of those. It wasn't until I was studying my Mega that I realized about the 16U2. I'm an old electronics nerd (broadcast radio technician for 20 years), and although I've been aware of the Arduino world for a long time, it's only recently that I'm really getting into them. Thank you for pointing this out; you've caused me to re-think my design.

westfw:
The 16u2 has the advantage that you can re-program it to provide a different usb service other than just usb/serial. Iirc, game controller and midi were popular.

Westfw, that's exactly what I'm looking for, but I want to work with HID keyboards. My original plan was a Nano with two USB host shields, and Oleg's USB Host Libraries for the MAX3421E. Now I have to decide if I should stick with two of those, or change it to one and use the USB connection of the 16U2 (or 32U4) for the other USB connection.

The 16u2 or 32u4 is useless for talking to a HID keyboard. AFAIK, they are "USB Device" only.
SAMD-based boards should have USB Host capabillitiy.

westfw:
AFAIK, they are "USB Device" only.

That could still work for my design, I just have to think it through.