cuprio

Designing a PCB with the CH340

The CH340 is WCH's USB-to-serial bridge: a full-speed USB device that appears as a serial port and drives a UART at 50 bps to 2 Mbps. It needs very few parts: 0.1 µF on VCC, 0.1 µF on the V3 pin at 5 V, D+ and D− wired straight to the connector, and a 12 MHz crystal only on the CH340G, T and R. The variant you pick decides the package, the clock and the temperature range.

  • 3 min read
  • 6 sections
  • 2 sources
Function
USB 2.0 full-speed device to UART, 50 bps to 2 Mbps, with RTS, DTR, DCD, RI, DSR and CTS
Supply
5 V (4.0 to 5.3 V) or 3.3 V with V3 tied to VCC (2.9 to 3.6 V for G/T/R, 3.1 to 3.6 V for the others)
Clock
12 MHz crystal on CH340G/T/R; built-in clock on CH340C/N/K/E/X/B
USB pins
Built-in transceiver and pull-up; UD+ and UD− connect without series resistors
Packages
SOP-16 (G, C, B), SOP-8 (N), ESSOP-10 (K), MSOP-10 (E, X), SSOP-20 (T)
Operating temperature
−40 to 85 °C for G/T/R; −20 to 70 °C for C/N/K/E/X/B

Which CH340 should I use?

  • CH340G (SOP-16): needs a 12 MHz crystal and covers −40 to 85 °C.
  • CH340C (SOP-16): same package with a built-in clock; its XI pin must be left unconnected.
  • CH340N (SOP-8): the smallest. It brings out TXD, RXD and RTS# only, with no DTR#.
  • CH340K (ESSOP-10): built-in diodes stop a separately powered MCU from feeding current into it through TXD, RTS# and RXD.
  • CH340E and CH340X (MSOP-10): the X adds 5 V-tolerant I/O at a 3.3 V supply, and its pin 6 can become DTR#.
  • CH340B (SOP-16): an EEPROM holds a custom serial number. The CH340R is discontinued.

How do I power the CH340 at 5 V or 3.3 V?

At 5 V, feed VCC and put a 0.1 µF capacitor on V3, the decoupling point for the internal 3.3 V node. At 3.3 V, tie V3 to VCC and keep every circuit connected to the CH340 at 3.3 V or below. VCC always gets its own 0.1 µF, both capacitors close to their pins. A CH340 at 5 V drives its outputs to nearly 5 V, so pair a 3.3 V microcontroller with a CH340 on the same 3.3 V rail.

Back-powering is the subtle problem. If the product has its own supply, WCH recommends running the CH340 from it rather than from VBUS, or joining USB 5 V and the board's 5 V through about 1 Ω. If the CH340 runs from VBUS and the MCU from its own rail, the datasheet adds Schottky diodes and a small NMOS so neither side powers the other through the UART pins, plus a 2 to 22 kΩ pull-up on the MCU's RX pin.

Does the CH340 need a crystal?

Only the G, T and R. They take 11.98 to 12.02 MHz on XI; WCH's application circuit uses a 12 MHz quartz crystal with 33 pF capacitors, and a ceramic resonator with its maker's values, typically 47 pF. The crystal-less parts trade accuracy for parts count: their internal clock is within ±1.2 % from −5 to 55 °C and ±1.8 % from −25 to 75 °C. The CH340 accepts about 2 % error on received data, and its transmit error is under 0.3 % with a crystal and under 1.8 % without, so the crystal parts leave more margin.

How do I wire D+, D− and the MCU reset?

The USB transceiver and the D+ pull-up are inside the chip, so UD+ and UD− go straight to the connector with no series resistors. WCH asks for the two lines run close and parallel with ground on both sides, as a short differential pair over a ground plane. Keep the XI and XO traces short too. A hand-plugged connector is also a good place for ESD protection.

For automatic programming, DTR# and RTS# drive an MCU's BOOT and reset pins. On the CH340X, a 4.7 kΩ pull-down on pin 6 turns TNOW into an open-drain DTR# that defaults low, and a 4.7 kΩ resistor from pin 6 to pin 5 gives a push-pull DTR# that defaults high. To keep a manual reset button on NRST, put 1 to 2 kΩ between RTS# and NRST.

Common CH340 mistakes

  • Adding 22 Ω series resistors or an external D+ pull-up: both are already inside the chip.
  • Leaving V3 open at 5 V, or not tying it to VCC at 3.3 V.
  • Fitting a crystal-less CH340C, N, K, E, X or B in a product that must work below −20 °C or above 70 °C.
  • Swapping a CH340C into a CH340G layout and leaving the crystal wired to its XI pin.

Checking a CH340 board

Cuprio picks real parts with live stock and checks the schematic with electrical rule checks.

Sources

  1. WCH: CH340 Datasheet (CH340DS1)

    Variants and packages, pins, supply modes and ranges, V3 and VCC capacitors, crystal and capacitor values, internal clock and baud-rate error, temperature ranges, USB wiring, backflow circuits, DTR and RTS download circuits

    wch-ic.com
  2. WCH: CH340DS1.PDF download page

    Datasheet version and the variants it covers

    wch-ic.com
Close view of the two-wheel robot controller, a board designed in Cuprio

Be first in when we open.

Start with 600 welcome credits and get 30% off your first 12 months.