Skip to the content.

E21 — Clock builds inside the datasheet and RM limits

   
ID E21
Date 2026-12-03
Status done
Decisions D99 (DECISIONS.md)
Board #1 (rev A, 12 MHz HSE), RP on the direct PC port
Firmware + results fw/tests/2026-12-03-1-clocks-v5fdvp-sdorder (final sources, 7 CH32 builds, results.txt)
Scripts clockspec.py, clockspeed.py

Summary: The ×40 build ran the V5F at 480 MHz (limit 400) and the 156 MHz build reads flash above the RM’s 150 MHz: builds now refuse out-of-spec clocks, the flash clock follows the RM, and ×24 (V3F 144, V5F 288 MHz) is the fastest in-spec build; default stays ×32.

What

Clock chain (RM V1.8 §3 clock tree): SYSCLK → HPRE → V5F → FPRE → V3F/HCLK. New RP417_HPRE; #error for V5F > 400 or HCLK > 160 MHz (DS V1.9). Flash interface clock SCK_CFG from HCLK per RM 46.4.1 (/1 ≤ 75 MHz, /2 ≤ 150 MHz, /4 “HCLK max 150, not recommended for reads”). Per build: V5F clock measured (mcycle vs SysTick); for each SCK, flashsum (FNV over the image, 32 reps, loop in RAM) vs the host, V3F flash and RAM loop; then the clockspeed.py suite.

Results

build V3F / V5F MHz (measured V5F) default SCK flash loop ms at /4, /2, /1 RAM loop ms suite
×32 (default) 96 / 384 (384.00) /2 415, 218, 120* 17.75 all pass, 11/11
×40 + HPRE 2 + FPRE 2 120 / 240 (240.00) /2 332, 175, hangs 14.20 all pass
×24 + FPRE 2 144 / 288 (288.00) /2 277, 146, chip resets 11.83 all pass, ADC1 5.13 MS/s, HSADC 96 MHz
×26 + FPRE 2 (E19) 156 / 312 (312.00) /4 (out of RM range) 255, 134, chip resets 10.93 all pass

Lesson

Read the RM register description for every clock you raise, not only the datasheet’s core limits: the flash has its own (150 MHz HCLK) limit below the core’s (160 MHz). Make out-of-spec builds fail at compile time.

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