E14 — V3F code from flash vs RAM
| ID | E14 |
| Date | 2026-12-02 |
| Status | done |
| Decisions | D90 (DECISIONS.md) |
| Board | #1 (rev A, 12 MHz crystals) |
| Firmware + results | fw/tests/2026-12-02-10-adcdual-v5f-flash (sources, binaries, results.txt) |
| Scripts | v5fbench.py, usbfs.py |
Summary: The V3F runs a loop ≈ 15× faster from RAM than from flash (no V3F I-cache); USB ISR in RAM: IN 525 → 880 kB/s, OUT → 775 kB/s.
What
Same 10-instruction loop compiled into flash and into RAM, timed at HCLK 48 and 96 MHz, with FLASH enhanced read mode off/on; then the USBFS interrupt handler moved to RAM and E9 re-run.
Results
| V3F loop (131072 iterations) | 96 MHz | 48 MHz |
|---|---|---|
| flash | 262 ms (192 cycles/iteration) | 284 ms |
| flash + enhanced read (EHMOD) | 218 ms | 240 ms |
| RAM | 17.8 ms (13 cycles/iteration) | 35.5 ms |
- Flash code hardly scales with the clock (−8 % for 2× HCLK): the “same rate at 48 and 96 MHz ⇒ not CPU-bound” test used in E9 is invalid for flash code.
- RM V1.8 p. 6: only the V5F has an instruction cache; shared SRAM is the V3F’s zero-wait code area.
- USBFS on the same hub path with the ISR in RAM: IN 874–887 kB/s (13.7 packets/ms), OUT 770–775 kB/s, 0 errors.
- Probably understated earlier numbers: ADC1 polling (343–360 kS/s), DVP chunk re-arm, SD per-command overhead, E6 clock-scaling comparisons.
Lesson
Benchmark where the code runs (flash vs RAM) before calling a result CPU-limited.
Chip facts and numbers: fw/LEARNINGS.md. All experiments: index.