Practical lessons from building USB HID devices on WCH CH32V series RISC-V microcontrollers, covering transceiver wiring, descriptor alignment, and debug tooling.
Pitfall 1: CH32V USB has no on-chip transceiver
The USB peripheral in CH32V devices does not include a built-in USB transceiver. You must connect an external transceiver, or use a board that already has one, such as an official WCH evaluation board.A common first-run failure is swapping DP and DM. If the D+ and D- lines are reversed, the host will never see the device enumerate. Double-check the schematic against the chip pinout before powering up.
Pitfall 2: Descriptor tables must respect byte alignmentWCH provides example projects for USB device, HID, CDC, and host modes. These examples are a good starting point: keep the endpoint and descriptor framework, then customize the report descriptor and endpoint configuration for your application.
The place where subtle bugs hide is descriptor alignment. The device descriptor, configuration descriptor, interface descriptor, and HID report descriptor are arrays of bytes. If the compiler inserts padding between entries or if a multi-byte field is not little-endian as expected, the host will reject the device. Verify the generated binary with a USB analyzer if enumeration still fails after checking wiring.Pitfall 3: Use WCH-Link for download and debug
For RISC-V MCUs, WCH-Link is the simplest debug interface. It handles both code download and on-chip debug, which saves time compared to wiring up a generic JTAG/SWD probe. If you are moving from Arm to RISC-V, budgeting for a WCH-Link is worthwhile.Recommended workflow
When to choose which CH32V part