Skip to the content.

CH32H417 bugs and pitfalls found on rp417

What the CH32H417 (silicon, WCH library, documentation, tools) did that we did not expect, found on board #1 (MEU6, QFN88). Each row has its workaround and source (experiment page, decision, fw/LEARNINGS.md). Kind: chip = silicon or peripheral behaviour, lib = WCH EVT / SDK code, doc = datasheet / reference manual gap, tool = flashing and host tools. This file is the source of Annex C of the datasheet (make -C datasheet).

ID Kind Area What happens Workaround Source
H1 lib RCC / USBHS PLL RCC_USBHSPLLReferConfig() ORs the REFSEL value (0–3) into PLLCFGR2 without shifting it to bits [3:2]: the 480 MHz PLL gets the wrong reference and USB HS never enumerates on a non-25 MHz crystal Write RCC_PLLCFGR2 directly (12 MHz HSE: PLLCLK/8, REFSEL 24 MHz → 0x0008072b) E27, D105
H2 chip DMA (DVP) DMA addresses must be 32-byte aligned (256-bit bus): with a 16-byte-aligned ring the last 16 bytes of each pass are never written, with no error flag Align every DMA buffer and ring slot on 32 bytes (or more) E28, D107
H3 chip USBSS PLL USBSS_PLLRDY sets for every REFSEL value even when the output is wrong (125 MHz × f_HSE / f_REFSEL): the lock flag does not prove a correct clock Use a 20–80 MHz reference matching REFSEL (25 MHz HSE); check the clock on MCO (mco ss2) E25, D103
H4 chip V3F core The V3F has no instruction cache: code runs ≈ 12–15× slower from flash than from RAM, and barely speeds up with HCLK Put ISRs, polling loops and re-arm paths in RAM; heavy work on the V5F (32 KB I-cache) E14, E16, D90
H5 chip Shared SRAM Shared SRAM contends per 128 KB block: DMA into the block holding V3F RAM code slows that code; a V5F loop hammering one shared word locks the V3F out Split code, DMA buffers and mailbox into separate 128 KB blocks; pace V5F polling E17, E20, D98
H6 chip SDMMC Writing a non-zero BKNUM (BLOCK_CFG) starts a data transfer at once: restoring BLOCK_CFG after CMD6 armed a 512-byte receive that overwrote 448 bytes of RAM at every high-speed switch Write BKNUM = 0 when idle; only set it right before a data command E13, D91
H7 chip SDMMC DMA address written before BLOCK_CFG: the first read after init loses its first 32-bit word when the code is slow Write DMA_BEG1 after BLOCK_CFG (WCH EVT order) E18, E24, D101
H8 chip SDMMC Back-to-back commands at the 100 kHz init clock give index errors (looks like a shifted CID) Wait for CMD high + ≥ 16 clocks before each command B2, D75
H9 chip SDMMC In high-speed mode the controller keeps data across reads: the first read of a different length after CMD18 returns wrong bytes or INT_FG 0x8080 Pulse CONTROL.RST_LGC before every read D86
H10 chip SDMMC NEGSMP (falling-edge sampling) gives CRC errors at 48 MHz high speed (passes by luck at some clocks) Sample on the rising edge (or PHASEINV) D86
H11 chip ADC1 Calibration result is bimodal (≈ ±7 LSB between runs) Calibrate several times / take the mode, or correct against a reference E3, D82
H12 chip ADC1 ADC input buffer off + high-impedance source at 5 MS/s gives wrong values (+365 / +50 / −173 LSB) Keep the ADC buffer on, or drive the pin from a low impedance E11, D87
H13 chip ADC1 5 MS/s needs the ADC clock from the USBHS PLL (/6 = 80 MHz); with this source DC noise is sd 3–9 LSB vs < 1 LSB at slow sampling Accept the noise or average; slow sampling for DC E11, D87
H14 doc HSADC HSADC at 192 MHz (above the 100 MHz limit) returns garbage without any flag Stay ≤ 100 MHz (PLL/(div+1)) B3, D79
H15 chip DVP In JPEG mode a VSYNC edge alone only sets STR_FRM: data is stored from the next HSYNC rising edge Drive HSYNC high after VSYNC falls (static HSYNC) E1, D81
H16 chip USBHS A burst stays armed after the device stops (overrun): the next host read receives it Drain EP1 IN before each run; tag runs with an id E28, D109
H17 chip Clocks V3F and V5F share the system PLL: a V3F clock choice moves the V5F too (×26: V3F 156, V5F 312 MHz) Choose the PLL for the V5F, the FPRE divider for the V3F; builds refuse out-of-spec clocks E19, E21, D99
H18 doc Flash Flash interface clock limits (≤ 75 MHz /1, ≤ 150 MHz) are only in the RM; a 156 MHz HCLK reads flash out of spec SCK_CFG from HCLK per RM 46.4.1 E21, D99
H19 chip Boot / ISP USB ISP on PA11/PA12 needs DP high at power-on and not afterwards; only a blank chip enters it on rev A UART ISP on PA9/PA10 after a power cycle (always listens at 115200) B1, D73
H20 tool ISP chip_id 0x71 (MEU6) is missing from wchisp 0.3.0 (only QEU6 0x70 upstream); minichlink reports “Unknown chip type” fw/tools/wchuart.py (Python port of the protocol) B1, D73
H21 chip SDI 1-wire SWIO sessions after the first one fail at random (rev A has no pull-up; the H417 debug module may also play a part) UART ISP; rev B pull-up B1, TODO item 2
H22 tool Toolchain Code put in section(".data") can fail to assemble (“ignoring changed section attributes”) Use section(".data.ramcode") (still copied to RAM, marked executable) E15, D92
H23 doc QSPI Quad data phase (CCR DMODE = 11) drives only IO0/IO1 unless CR bit 13 SIOXEN is set; the QSPI chapter does not say so Set SIOXEN for dual/quad modes E29, D113
H24 chip QSPI A transfer that cannot complete (SCK = HCLK/1) leaves SR BUSY set for good; abort does not clear it, the next wait hangs Reset QSPI2 through RCC (HB1PRSTR) before each set-up E29, D113
H25 doc ECDC Single-block mode wants the 128-bit input fully byte-reversed (SGSD_127T96 = bswap(word 3) … SGSD_31T0 = bswap(word 0)) while the outputs and RAM mode are in memory order Byte-reverse in software for single blocks, or use RAM (DMA) mode E34, D115
H26 chip RNG Output has little entropy: only ~800 distinct 32-bit words in 2048 reads (one value 18 times), byte χ² 1 200–9 400 for 255 dof on 2048 words, same with either RNG clock source and any read pace Never use directly; at most a seed for a DRBG with a large input (hash many words) E34, D115
H27 chip I2C Slave mode: the register byte written just before a repeated start is sometimes lost (read starts at the old pointer) Master sends STOP between the register write and the read E31, D114
H28 doc PWR Stop-mode wake-up measured 21.8 µs (LPDS 0) / 52.8 µs (LPDS 1) at the first handler instruction, vs DS typ 4 / 35 µs Budget ≥ 25 / 55 µs; use WFI sleep (1.25 µs) when latency matters E32
H29 tool Clocks / Flash ch32fun SystemInit() for the H41x switches SYSCLK to the PLL (HCLK = PLL/4) without setting FLASH ACTLR SCK_CFG, which resets to 0 (flash at HCLK/1): 96–120 MHz flash reads, out of the RM ≤ 75 MHz range, until the application changes it; at ×40 some code layouts hang at boot Set SCK_CFG before calling SystemInit() E35, E37, D117