Skip to the content.

E32 — CH32 response latency: interrupt, polling, sleep and stop wake-up

   
ID E32
Date 2026-12-04
Status done (V3F 96 MHz): EXTI interrupt 0.80–1.36 µs, polling 93–267 ns, WFI sleep 1.25 µs ± 6 ns, Stop 21.76 µs and Stop + LPDS 52.8 µs (DS: 4 / 35 µs), jitter ≤ 7 ns; handlers from flash ~2× slower
Decisions D112 (DECISIONS.md)
Board #1 (rev A), CH32 ×32 (HCLK 96 MHz)
Firmware + results fw/tests/2026-12-04-1-links (rp417_ch32.bin = handlers in RAM, rp417_ch32_ramloops0.bin = in flash), raw: latency.txt
Scripts links_latency.py; CH32 lat <irq\|poll\|sleep\|stop\|stoplp> <edges>; RP lat <n> <gap_us> <limit_us>

Summary: The RP toggles LOGIC4 (GPIO16 → CH32 PD10) and a PIO loop counts until MARK (CH32 PB14 → RP GPIO33) follows. The CH32 copies PD10 to PB14 in one of five ways. Resolution is 13.3 ns per count (2 PIO cycles at 150 MHz), 1000 edges per mode (300 for the stop modes, 3 ms apart).

Results

mode (V3F 96 MHz) how the CH32 answers rise min / p50 / p99 / max sd
poll RAM loop reads INDR, writes BSHR 93 / 187 / 267 / 267 ns 53 ns
irq EXTI10 → EXTI15_8 handler (RAM) 800 / 880 / 1347 / 1360 ns 140 ns
sleep WFI, EXTI wakes, handler 1240 / 1253 / 1253 / 1253 ns 6 ns
stop PWR Stop (LPDS 0), SLEEPDEEP + WFI 21.76 µs (all) 0
stoplp Stop with LPDS = 1 (regulator low power) 52.81–52.84 µs 7 ns

Handlers and loops in flash (RP417_RAMLOOPS=0): irq 1.84–2.39 µs, poll 0.41–2.64 µs (sd 634 ns), sleep 2.28 µs.

Lesson

Measure latency against a timer that is not on the chip under test: the RP PIO gives 13 ns resolution for free. Keep wake-up handlers in RAM: flash doubles the latency.

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