Lib-electronic-components wch

WCH (Nanjing Qinheng Microelectronics) MPN encoding patterns, suffix decoding, and handler guidance. Use when working with WCH RISC-V MCUs, USB interface chips, or WCHHandler.

install
source · Clone the upstream repo
git clone https://github.com/Cantara/lib-electronic-components
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/Cantara/lib-electronic-components "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/manufacturers/wch" ~/.claude/skills/cantara-lib-electronic-components-wch && rm -rf "$T"
manifest: .claude/skills/manufacturers/wch/SKILL.md
source content

WCH (Nanjing Qinheng) Manufacturer Skill

MPN Structure

WCH has two main product categories with different structures:

RISC-V and ARM MCUs (CH32 Series)

CH32[CORE][SERIES][PIN][FLASH][PKG][TEMP]
│     │      │     │     │     │     │
│     │      │     │     │     │     └── Temperature (6=industrial)
│     │      │     │     │     └── Package type (T=LQFP, U=QFN)
│     │      │     │     └── Flash size (4=16KB, 8=64KB, B=128KB, C=256KB)
│     │      │     └── Pin code (C=48, R=64, V=100)
│     │      └── Series (003=entry, 103=standard, 203=enhanced, 30x=high-perf)
│     └── Core (V=RISC-V, F=ARM Cortex-M3)
└── CH32 prefix

USB Interface Chips (CH34x Series)

CH[SERIES][VARIANT]
│    │       │
│    │       └── Package variant (G=SOP-16, C=SOP-16 w/crystal, K=ESSOP-10)
│    └── Series (340=USB-UART, 341=USB-Multi, 9340=Enhanced)
└── CH prefix

Example Decoding

CH32V103C8T6
│   │  │ │││
│   │  │ ││└── Temp 6 (industrial)
│   │  │ │└── Package T (LQFP)
│   │  │ └── Flash 8 (64KB)
│   │  └── Pin C (48-pin)
│   └── Series 103 (QingKe V3A core)
└── Core V (RISC-V)

CH340G
│  │ │
│  │ └── Package G (SOP-16)
│  └── Series 340 (USB to UART)
└── CH prefix

Package Codes

MCU Pin Codes

CodePackagePin Count
AQFN-2828
CLQFP-4848
FTSSOP-2020
GQFN-2020
JSOP-2020
KESSOP-2020
NSOP-88
RLQFP-6464
UQFN-2020
VLQFP-100100
WQFN-2828

USB Interface Chip Packages

SuffixPackage
GSOP-16
CSOP-16 (integrated crystal)
KESSOP-10
NSOP-8
EMSOP-10
XESSOP-10
TSSOP-20
ASOP-28
BSSOP-28
SSOP-28
HSOP-28
LLQFP-48

Product Families

RISC-V MCUs (CH32Vxxx)

SeriesCoreClockFeatures
CH32V003QingKe V2A48MHzEntry-level, 2KB SRAM
CH32V103QingKe V3A80MHzStandard, 20KB SRAM
CH32V203QingKe V4B144MHzEnhanced, 64KB SRAM
CH32V208QingKe V4C144MHzBluetooth LE support
CH32V303QingKe V4F144MHzHigh-performance
CH32V305QingKe V4F144MHzUSB HS, Ethernet
CH32V307QingKe V4F144MHzUSB HS, Ethernet, CAN

ARM Cortex-M3 MCUs (CH32Fxxx)

SeriesCoreClockFeatures
CH32F103Cortex-M372MHzSTM32F103 compatible
CH32F203Cortex-M3144MHzEnhanced peripherals

USB Interface Chips

SeriesTypeFeatures
CH340USB-UARTMost popular, no crystal needed (CH340C)
CH341USB-MultiUART/I2C/SPI/Parallel
CH9340USB-UARTEnhanced CH340
CH342-CH348USB-UARTVarious channel counts

Other Interface Chips

SeriesTypeFeatures
CH395Ethernet10/100M Ethernet controller
CH9121ETH-UARTEthernet to serial
CH9141BLE-UARTBluetooth LE module
CH9143BLE-UARTBluetooth LE module
CH334USB HubUSB hub controller
CH224USB PDPower Delivery controller
CH552/554/5598051 USB8051-based USB MCUs

Flash Size Encoding

CodeFlash Size
416KB
632KB
864KB
B128KB
C256KB
D384KB
E512KB
G1024KB

Handler Implementation Notes

MCU Package Code Extraction

// MCU format: CH32V103C8T6
// Position:   01234567890123
//                    ^-- position 8 is pin code 'C'
char pinCode = mpn.charAt(8);
String packageType = MCU_PACKAGE_CODES.get(pinCode);

// Pin count also at position 8
Integer pinCount = MCU_PIN_COUNTS.get(pinCode);

USB Interface Package Extraction

// CH340G -> G = SOP-16
// Last character is package code
String suffix = mpn.substring(mpn.length() - 1);
String pkg = USB_PACKAGE_CODES.get(suffix);

// CH340 without suffix defaults to SOP-16
if (mpn.matches("^CH(340|341|9340)$")) {
    return "SOP-16";  // Default package
}

Core Type Detection

The handler provides

getCoreType()
for MCUs:

SeriesCore Type
CH32V003RISC-V QingKe V2A
CH32V103RISC-V QingKe V3A
CH32V203/208RISC-V QingKe V4B
CH32V303/305/307RISC-V QingKe V4F
CH32F103/203ARM Cortex-M3
CH552/554/5598051 Enhanced

Interface Type Detection

The handler provides

getInterfaceType()
for interface chips:

SeriesInterface Type
CH340, CH9340USB to UART
CH341USB to UART/I2C/SPI/Parallel
CH348USB to 8x UART
CH395Ethernet Controller
CH9121Ethernet to UART
CH9141/9143BLE to UART
CH334USB Hub Controller
CH224USB PD Controller

Related Files

  • Handler:
    manufacturers/WCHHandler.java
  • Component types:
    MICROCONTROLLER
    ,
    IC

CH340 vs CH340C

The CH340C has an integrated crystal oscillator:

  • CH340G: Requires external 12MHz crystal
  • CH340C: No external crystal needed (recommended for new designs)

Both are SOP-16 package and pin-compatible.


STM32 Compatibility

CH32F103 series is designed as a drop-in replacement for STM32F103:

  • Same pinout and package options
  • Same peripheral registers
  • Lower cost alternative
  • Note: Not 100% register-compatible, test thoroughly

Learnings & Edge Cases

  • QingKe cores: WCH's proprietary RISC-V core implementations (V2A, V3A, V4B, V4C, V4F)
  • CH32V003 popularity: Entry-level RISC-V MCU, extremely low cost (~$0.10)
  • CH340 dominance: Most common USB-UART chip in Arduino clones and hobbyist boards
  • Position-based extraction: MCU pin code at position 8, flash at position 9
  • Flash code reuse: Same encoding as STM32 (8=64KB, B=128KB, C=256KB)
  • CH32F vs STM32F: Pin-compatible but register differences exist, verify before migration
  • Temperature code: 6 = industrial (-40 to +85C) is standard for all CH32 MCUs
<!-- Add new learnings above this line -->