Skip to the content.

E29 — RP ↔ CH32 QSPI link (QSPI2 ↔ RP PIO)

   
ID E29
Date 2026-12-04
Status done: CH32 → RP 0 errors up to SCK 48 MHz (24 MB/s); RP → CH32 0 errors up to 19.2 MHz, 32 MHz (16 MB/s) with the RP input synchronisers bypassed; 1.1 MB soak each way at those settings, 0 errors
Decisions D112, D113 (DECISIONS.md)
Board #1 (rev A, Y2 = 12 MHz), CH32 ×32 build (HCLK 96 MHz), RP clk_sys 150 MHz
Firmware + results fw/tests/2026-12-04-1-links (both chips; CH32 = bin/rp417_ch32.bin), raw: docs/bench/2026-12-04-links/qspi.txt
Scripts links_qspi.py, links_lib.py; firmware fw/ch32/links.c (qspiw, qspir), fw/rp/src/links.c + links.pio (qspi rx/tx/chk/stop)

Summary: The CH32’s QSPI2 controller (PE10–PE15, AF7) is the master. The RP plays the “flash” with two PIO programs: qspi_rx samples 4 bits on each SCK rising edge while nCS is low, and qspi_tx drives 4 bits on each falling edge. DMA fills or drains a 64 KB buffer. Both sides generate the same xorshift32 byte pattern, so every byte is checked. The CH32 → RP direction is clean up to SCK = HCLK/2 = 48 MHz. The RP → CH32 direction is clean up to 19.2 MHz with the RP input synchronisers on, and up to 32 MHz with them bypassed. Three CH32 behaviours had to be found first: SIOXEN, a stuck BUSY flag, and the pin state after release.

What

Results

SCK CH32 → RP (write), sync on sync bypassed RP → CH32 (read), sync on sync bypassed
8 MHz 0 / 98304 61165 bad 0 0
12 MHz 0 75232 bad 0 0
16 MHz 0 72572 bad 0 0
19.2 MHz 0 56137 bad 0 0
24 MHz 0 61106 bad 93574 bad 0
32 MHz 0 66774 bad 94920 bad 0
48 MHz 0 (23.97 MB/s) 50677 bad 97900 bad 97936 bad
96 MHz all bad all bad — —

Soak: write 48 MHz (sync on) 0 bad of 1 146 880 bytes; read 32 MHz (sync bypassed) 0 bad of 1 146 880 bytes.

Lesson

A result that is the same at every setting points at the test, not the link. “All reads bad” came from a hang left by the 96 MHz write. Rerun one failing point by hand right after the step before it, rather than theorising on the table.

Chip facts and numbers: fw/LEARNINGS.md. All experiments: index.