E19 — V3F at 156 MHz
| ID | E19 |
| Date | 2026-12-02 |
| Status | done |
| Decisions | D97 (DECISIONS.md) |
| Board | #1 (rev A, 12 MHz HSE) |
| Firmware + results | fw/tests/2026-12-02-12-ramloops-v5f-156mhz (rp417_ch32_mul26_fpre2.bin = 156 MHz, rp417_ch32_mul32.bin = default, results.txt) |
| Scripts | clockspeed.py, v5fbench.py, ramloops.py, dvpv5f.py |
Summary: PLL ×26 = 312 MHz with FPRE /2 runs the V3F at 156 MHz (DS: ≤ 160 MHz) and passes every check; the V5F drops to 312 MHz because both cores share the PLL, so ×32 (96/384 MHz) stays the default.
What
ch32fun always sets FPRE /4 (V3F = PLL / 4). RP417_FPRE=2 switches it to /2 in main() after moving the flash
interface clock to HCLK/4 (as WCH/WeAct’s 143.75 MHz V3F setup). The V5F takes SYSCLK = PLL directly, so the PLL must
stay ≤ 320 MHz for the V3F’s 160 MHz limit.
Update 2026-12-03 (E21, D99): HCLK 156 MHz runs the flash above the 150 MHz HCLK that RM V1.8 46.4.1 allows, although every check below passed. The fastest in-spec build is ×24 + FPRE /2 (V3F 144 MHz, flash at HCLK/2); see E21.
Results
| 96 MHz V3F (×32, FPRE /4) | 156 MHz V3F (×26, FPRE /2) | |
|---|---|---|
| V5F clock | 384 MHz | 312 MHz |
| selftest, timebase (RP 12.5 MHz counted) | 11/11, +27.8 ppm | 11/11, +27.8 ppm |
| V3F ALU loop from RAM | 17.75 ms | 10.93 ms (×1.62 = 156/96) |
| V3F ALU loop from flash (EHMOD) | 218 ms | 255 ms (slower: flash interface HCLK/4 = 39 MHz vs HCLK/2 = 48 MHz) |
| V5F ALU loop (flash, I-cache) | 2.06 ms | 2.53 ms |
| V5F shared-RAM sum, 8192 words × 16 | 1834 µs | 1485 µs (shared RAM paced by HCLK) |
| ADC1 DMA, HCLK/2, 1.5 cycles | 3.42 MS/s (48 MHz) | 5.55 MS/s (78 MHz, DS ≤ 80 MHz) |
| HSADC (SYSPLL / (div + 1) ≤ 96 MHz) | 19.0 MS/s at 96 MHz | 15.5 MS/s at 78 MHz (312/3 = 104 is over) |
| SD 64-block reads 24 / 48 MHz | 7.9 / 11.8 MB/s | 7.8 / 11.3 MB/s (48 MHz → 44.6 MHz, div 7) |
| SD CMD6 high speed, 4 MB verified stream | ok | ok |
| DVP 75 MHz, 256-sample chunks, 2 s | 0 bad | 0 bad |
| die temperature | 35.5 °C | 36.0 °C |
- ch32fun
DELAY_US_TIME= HCLK/8/10⁶ is an integer: 19 instead of 19.5 at 156 MHz, so every µs figure read 2.6 % high (rates 2.6 % low) until the firmware switched to DELAY_MS_TIME for conversions. - A polling V5F slowed V3F RAM code 1.66× at 156 MHz, first blamed on the 2:1 clock ratio; the cause was the mailbox
sitting in the V3F RAM-code block (E17). With the mailbox in
.bss, no effect at either clock. - Flash code gets slower at 156 MHz (flash clock HCLK/4): keep time-critical code in RAM, which E16 already does.
Lesson
Running the CH32’s main core at 156 MHz means slowing its second core from 384 to 312 MHz, because both share one clock. Pick the split per experiment. And check printed rates against a known source after any clock change: ch32fun’s integer µs constant was 2.6 % off at 156 MHz.
Chip facts and numbers: fw/LEARNINGS.md. All experiments: index.