Author Topic: CH340 & AVR - proper external + internal power supply  (Read 587 times)

0 Members and 1 Guest are viewing this topic.

Offline nemail2Topic starter

  • Regular Contributor
  • *
  • Posts: 206
  • Country: at
CH340 & AVR - proper external + internal power supply
« on: November 20, 2021, 08:43:16 pm »
Hi

if I have a device which is powered by an internal voltage source and that has an AVR (1284p in that case)@5V + a CH340@5V for USB/UART conversion, how do I properly connect the 5V lines?

If I connect the AVR to the 5V of the USB port and the CH340, the AVR will get voltage through USB, which I don't want. The device has a mains switch and should stay turned off, even with a USB cable connected to it.

If I connect the AVR to the internal voltage source and the CH340 to the USB 5V+ and the device is powered off, the CH340 will receive power from USB while the AVR is turned off and probably drive the RX/TX UART lines high which could light up the AVR through the RX/TX lines.

If I connect the AVR and the CH340 to the internal voltage source, and if the device is powered off, the CH340 may see voltage coming in from the PC through the D+/D- lines of the USB port, although VCC being 0V.

I'd like to be able to leave the USB cable connected to the device all the time without powering anything parasitically through data lines.
Is there an easy, proper way to do this or would I just do the last option and ignore the D+/D- lines?

Thanks!
Boron rhymes with moron
 

Online magic

  • Super Contributor
  • ***
  • Posts: 6779
  • Country: pl
Re: CH340 & AVR - proper external + internal power supply
« Reply #1 on: November 22, 2021, 04:09:06 pm »
Not sure about CH340 but some USB devices like FT232 can tolerate USB signals while being unpowered (as may occur in a self-powered application).

Interestingly, FT232 datasheet also recommends keeping the chip in reset while USB is disconnected because otherwise the chip would apply 3.3V pullup to the data lines which reportedly causes incorrect operation of some USB hubs when the device is finally connected.

One option which sidesteps all problems at the cost of two components:
- add a diode so that CH340 TX can only pull down
- pull up MCU RX to the external supply with a resistor
 
The following users thanked this post: nemail2


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf