CH32V003 from WCH is a RISC-V microcontroller that sells for a few cents – yet it runs at 48 MHz and works at both 3.3 V and 5 V. It has become a popular replacement for 8-bit AVRs and many “single-purpose” chips.
CH32V003F4P6 is the most common package, TSSOP20 with 18 GPIO. Its successor, the CH32V002F4P6, has the same layout.
Specifications
- RISC-V (QingKe V2A) at 48 MHz
- 16 kB flash, 2 kB SRAM
- 18 GPIO, 8 channels of 10-bit ADC, op-amp
- USART, I2C, SPI, TIM1 (advanced) and TIM2 timers, PWM
- 3.3 V or 5 V supply
- single-wire programming and debugging (SWIO on PD1)
- TSSOP20 package with 0.65 mm pitch
It is programmed with the WCH-LinkE (single-wire SWIO). You can choose MounRiver Studio, an Arduino IDE core, PlatformIO or the minimalist ch32fun. Peripheral functions can be remapped to other pins – the table shows the default layout as well as the remap options.
Pinout and pin table
Hover over a pin in the diagram or a table row; use the filter to highlight a bus. You can download the pinout as PNG or SVG.
| Pin | Name | Direction | UART | I2C | SPI | PWM | ADC | Remap | Note |
|---|---|---|---|---|---|---|---|---|---|
| 1 | PD4 | input/output | T2CH1ETR | A7 | 2: T1ETR; 3: T1CH4 | USART CK; OPA output | |||
| 2 | PD5 | input/output | TX | A5 | 2: RX; 3: T2CH4 | ||||
| 3 | PD6 | input/output | RX | A6 | 2: TX; 3: T2CH3 | ||||
| 4 | PD7 | input/output | T2CH4 | 1: CK; 2: T2CH4, CK | Reset (NRST) by default; usable as GPIO only after switching in the option bytes (RST_MODE = 11); op-amp input +1 | ||||
| 5 | PA1 | input/output | T1CH2 | A1 | 2: T1CH2 | Krystal (OSCI); op-amp input −0 | |||
| 6 | PA2 | input/output | T1CH2N | A0 | 1: ADC trigger (AETR2); 2: T1CH2N | Krystal (OSCO); op-amp input +0 | |||
| 7 | VSS | – | |||||||
| 8 | PD0 | input/output | T1CH1N | 1: SDA, TX; 2: T1CH1N | op-amp input −1 | ||||
| 9 | VDD | input | Power 3.3 V or 5 V | ||||||
| 10 | PC0 | input/output | T2CH3 | 1: NSS, T1CH3; 2: T2CH3; 3: TX | |||||
| 11 | PC1 | input/output | SDA | NSS | 1: T1BKIN, T2CH4; 2: T2CH1ETR; 3: T1BKIN, T2CH1ETR, RX | 5 V tolerant | |||
| 12 | PC2 | input/output | SCL | 1: ADC trigger (AETR), T2CH2, RTS; 2: T1BKIN; 3: T1ETR | USART RTS; T1BKIN; 5 V tolerant | ||||
| 13 | PC3 | input/output | T1CH3 | 1: T1CH1N, CTS; 2: T1CH3; 3: T1CH1N | |||||
| 14 | PC4 | input/output | T1CH4 | A2 | 1: T1CH2N; 2: T1CH4; 3: T1CH1 | clock output (MCO) | |||
| 15 | PC5 | input/output | SCK | 1: SCK, T1ETR, T2CH1ETR; 2: SCL; 3: SCL, T1CH3, CK | T1ETR; 5 V tolerant | ||||
| 16 | PC6 | input/output | MOSI | 1: MOSI, T1CH1; 2: SDA, CTS; 3: SDA, T1CH3N, CTS | 5 V tolerant | ||||
| 17 | PC7 | input/output | MISO | 1: MISO, T1CH2; 2: RTS; 3: T1CH2, T2CH2, RTS | |||||
| 18 | PD1 | input/output | T1CH3N | 1: SCL, T1CH3N, RX; 2: T1CH3N | Programming and debugging (SWIO, single wire – WCH-LinkE); ADC trigger (AETR2) | ||||
| 19 | PD2 | input/output | T1CH1 | A3 | 1: T2CH3; 2: T1CH1; 3: T1CH2N | ||||
| 20 | PD3 | input/output | T2CH2 | A4 | 1: T1CH4; 2: T2CH2 | USART CTS; ADC trigger (AETR) |
What to watch out for
- PD1 is the SWIO programming pin – if your program uses it for something else, uploading gets complicated. Leave it free.
- PD7 is reset (NRST) from the factory – free it up as GPIO in the option bytes (RST_MODE = 11).
- Logic levels follow the supply voltage – at 5 V the outputs are 5 V too.
- PA1 and PA2 are used for an external crystal – with a crystal they are not available.
- The ADC reference is the supply voltage.
CH32V articles on chiptron.eu/
These chiptron.eu/ articles cover the CH32V chips:
- CH32V003 in the Arduino IDE and on Linux – WCH-LinkE programmer, openOCD and the CH32fun alternative
More pinouts
See all pinouts on the Pinouts page.