E17 — V5F as a live DVP data checker
| ID | E17 |
| Date | 2026-12-02 |
| Status | done |
| Decisions | D95, D97 (DECISIONS.md) |
| Board | #1 (rev A), RP PIO counter → capture switch → CH32 DVP, 10-bit, PCLK up to 75 MHz |
| Firmware + results | fw/tests/2026-12-02-12-ramloops-v5f-156mhz (sources, binaries, results.txt) |
| Scripts | dvpv5f.py |
Summary: The V5F checks every sample of a 75 MS/s DVP stream while the V3F only re-arms (64–72 % V5F load, 0 bad samples, a broken stream is caught); a V5F loop that only reads shared RAM locks the V3F out completely.
What
First real job for the second core (E13). The V3F streams the DVP into a 64 K-sample ring (16–4096 slots) and counts chunks in the shared-RAM mailbox; the V5F (mailbox command 5, code in flash through its I-cache) follows the count and checks that every sample is the previous + 1 (mod 1024), reporting bad samples, lag and overruns.
Results
Every sample checked (dvpv5f, 2 s at 75 MS/s = 150 M samples; V5F load = time spent checking / stream time):
| chunk | 96 MHz V3F / 384 MHz V5F | 156 MHz V3F / 312 MHz V5F |
|---|---|---|
| 4096 | 0 bad, 64.0 % | 0 bad, 44.2 % |
| 1024 | 0 bad, 65.2 % | 0 bad, 45.0 % |
| 256 | 0 bad, 68.0 % | 0 bad, 47.8 % |
| 128 | 0 bad, 71.8 % | 0 bad, 51.5 % |
| 64 | 212 bad (V3F re-arm late), 79.4 % | 0 bad, 59.1 % |
| 1024 at 37.5 / 10 MS/s | 31.1 / 8.0 % | 21.9 / 5.7 % |
| control: 16 at 75 MHz (re-arm too slow) | 5.6 M bad samples caught | 3.8 M caught |
- The slower V5F checks faster: 44 % at 312 MHz vs 64 % at 384 MHz. Its reads from shared RAM are paced by HCLK (≈ 1.7 HCLK cycles per 32-bit word in both builds), not by its own clock.
- Lock-up: a V5F loop of back-to-back loads on one shared-RAM word (checker idle with 0 nops) stops the V3F completely (no console until a reset), at both clocks and wherever the word is; 1 nop between loads avoids it.
- Per-block contention: with the mailbox in the V3F RAM-code block (first build,
.data), a polling V5F slowed the V3F’s RAM loop from 17.75 to 37.5 ms (0 nops, 96 MHz) and 10.9 → 18.2 ms (156 MHz); 64-sample chunks then lost 414 k samples. In another 128 KB block (.bss): 17.751 / 10.925 ms at every polling rate. See E19 and D97.
Lesson
Give every polling loop on a second core a pause: a tight loop of loads on one shared-RAM word starved the other core until reset, and it looked like a firmware hang. A minimal debug command (start and stop the checker with no data) found it in one step.
Chip facts and numbers: fw/LEARNINGS.md. All experiments: index.