Skip to the content.

E16 — V3F polling loops from flash vs RAM

   
ID E16
Date 2026-12-02
Status done
Decisions D94 (DECISIONS.md)
Board #1 (rev A, 12 MHz crystals), HCLK 96 MHz (PLL ×32)
Firmware + results fw/tests/2026-12-02-12-ramloops-v5f-156mhz (sources, binaries rp417_ch32_mul32.bin = RAM, rp417_ch32_mul32_ramloops0.bin = flash, results.txt)
Scripts ramloops.py

Summary: Same source built twice (RP417_RAMLOOPS=0/1): from RAM, ADC1 polling follows the ADC up to 4 MS/s (flash: ≈ 0.45 MS/s) and the DVP re-arm handles 32-sample chunks at 75 MS/s (flash: 256 failed); SD per-command time does not change (the card sets it).

What

E14 showed V3F code runs ≈ 15× slower from flash than from RAM, so every “CPU-limited” result measured from flash was suspect. The three remaining polling paths (ADC1 polling, DVP chunk re-arm, SD command/data waits) got a RAMFN attribute; a build switch puts them back in flash for a clean A/B on the same source.

Results

ADC1 CPU polling, 4000 samples, ch 10 (rate in MS/s; the ADC’s own rate = f_ADC / (smp + 12.5)):

ADC clock, sample time ADC rate flash, 96 MHz RAM, 96 MHz RAM, 156 MHz
HCLK/2, 1.5 3.43 (96) / 5.57 (156) 0.49 3.43 5.57
HCLK/2, 7.5 2.40 / 3.90 0.40 2.40 3.90
HCLK/2, 28.5 1.17 / 1.90 0.41 1.17 1.90
USBHS/6 = 80 MHz, 1.5 5.71 0.49 4.57 (CPU limit) 5.71
80 MHz, 7.5 4.00 0.40 4.00 4.00
80 MHz, 28.5 1.95 0.46 1.95 1.95

DVP at 75 MHz PCLK (RP counter), V3F polls ROW_DONE and re-points the finished buffer:

  flash, 96 MHz RAM, 96 MHz RAM, 156 MHz
dvpcap, smallest clean chunk > 256 (256: 24 bad steps) 32 (16: 426 bad) 32 (16: 68 bad)
dvpstream 2 s, smallest clean chunk 512 (256: 288 k bad chunks) 64 (2.34 M re-arms, one per 853 ns) 64

SD, 4-bit (per-command path in RAM vs flash):

  flash RAM
1-block reads, 24 / 48 MHz 1576 / 1590 KiB/s 1654 / 1680 KiB/s (+5 %)
64-block reads, 24 / 48 MHz 7.8 / 11.6 MB/s 7.9 / 11.7 MB/s
1-block writes (2048, verified, window restored) 850–930 µs each 850–910 µs each

So the ADC and DVP limits from E1/B3 were the flash; the SD per-command time (≈ 300 µs read, ≈ 850 µs write) is the card’s.

Lesson

Move the loop, then re-measure with an A/B build of the same source: two of three “CPU limits” were the flash, the third (SD) was really the card.

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