How a backlight with nothing on it led through a SPI quirk, a stack overflow and a lesson in electromagnetism, and ended with a cost model that held on a second chip.
RV565 is a small video format I built for microcontroller screens. Each frame is compressed on its own with Deflate, the algorithm inside every .zip, and decodes straight into RGB565, the colour format SPI displays use. In the RV565 paper it plays at 24 frames per second on an ESP32-S3, with a cost model that predicts from the file alone whether a clip will keep up.
The obvious next question: does any of that hold on a different chip? So I got a Raspberry Pi Pico 2 and a 2.0" 320×240 ST7789 display, wired them on a breadboard, and flashed the benchmark.
The terminal said it worked: 24.00 FPS, zero dropped frames, zero missed deadlines.
The screen showed the backlight and nothing else.
A measurement can lie about the thing you care about
The benchmark times the microcontroller's own work: unpacking a frame, scaling it, handing it to the SPI hardware. Every number was plausible, because the Pico really was doing that work. It just had no idea whether the display understood any of it. SPI to a display is one-way: the Pico talks and never hears back.
So "24 FPS, 0 misses" and "blank screen" were both true at once. That's the first lesson: a fast benchmark tells you nothing about a correct one.
(There was an even earlier red herring. On the very first try the firmware never got onto the board at all. The Pico had shipped with MicroPython, the copy hadn't landed, and USB still reported a "MicroPython Board". Always check what's actually running before debugging what you think is running.)
Step 1: get a known-good reference
The display port for the Pico had never run on real hardware, so I didn't trust it. I needed something I did trust to tell me whether the wiring was fine.
So I flashed MicroPython back and drove the display by hand from the laptop: reset it, send the start-up commands one by one, fill the screen red, green and blue. Nothing clever, and all of it slow.
At 1 MHz it worked. At 10 MHz it worked. At 24 MHz it was blank.
The wiring was connected correctly. It just couldn't carry fast signals.
To find the exact limit, I wrote a firmware that tests every speed in one go. It starts the display at a safe 1 MHz, then for each speed it blanks the screen to black at 1 MHz and fills it with that speed's colour: white for 9.4 MHz, cyan for 12.5, yellow for 15, blue for 18.75, green for 25, red for 37.5. A colour only appears if that speed works, so the last colour you see is the limit. I like this trick: the test displays its own answer.
With long jumper wires: blank above about 10 MHz. With shorter wires: every colour, up to red.
Step 2: the screen still stayed blank
Back to the real benchmark at 37.5 MHz: blank again, even with the better wiring.
The speed test had drawn colours at 37.5 MHz, so what was different? Two things. The speed test sent its start-up commands at 1 MHz and only the pixels fast, while the benchmark sent everything fast. A self-test confirmed it: with start-up at full speed, nothing appeared at all.
So the fix: send command bytes at 10 MHz, and only pixel data at 37.5 MHz. The next run showed a flash of random noise, which is the display's memory appearing once it's awake, and that's actually good news. Then half a screen of red, then blank.
That's when I noticed the speed test had been flattering me. A display controller stays in "memory write" mode until it receives another command. In the speed test, each fast colour fill came right after a slow black fill, so the slow fill had already opened the write. The fast "memory write" command that followed could be garbled and it wouldn't matter. In the real benchmark, every frame's single command byte went out fast. So the per-frame command moved to 10 MHz too. It's half a microsecond per frame.
That half screen of red was also the first hint of what was coming: the display had started taking pixels, then lost track partway through. A 33 Ω resistor in series with the clock line, at the Pico end, made full-speed frames reliable.
Step 3: a free 15% from one line
Now the bars scrolled. The timing, though, had been bothering me since the first run. One frame is 1,228,800 bits; at 37.5 MHz that's 32.77 ms on the wire. The measured transfer took about 39 ms, so the bus ran at only 84% of its clock.
The RP2350's SPI block is an Arm PL022. In SPI mode 0 it leaves an idle gap of about one and a half clock cycles after every byte. That gives 8 bits in about 9.5 clock periods, which is 84.2%: almost exactly the measured 83.8%.
Mode 3 sends bytes back to back. The display reads data on the same clock edge in both modes, so it doesn't care which one you use. One changed line:
Step 4: the film vanished
Colour bars worked. Then I flashed a real film clip, a window of Big Buck Bunny, the same source the paper used.
Blank.
This time I had a specific suspect. In single-core ("serial") mode the decoder runs on core 0, keeps about 11 KB of state on the stack, and the Pico SDK gives core 0 only 2 KB of stack. The linker map confirmed it: a real overflow of about 9 KB. I fixed it by moving the decoder's state into static memory. It's a genuine bug, now fixed upstream.
The screen was still blank.
So, one variable at a time. Test pattern in serial mode: works. Film in dual-core mode: blank, except that "something appears in the centre for half a second, then disappears." The film itself was the trigger. And the same film at 25 MHz played perfectly.
Then the last clue arrived. After I added more resistors, the film stayed on screen, but in negative colours.
What was actually happening
Wires stop being wires
A digital edge switches from 0 to 3.3 V in a few nanoseconds. At that speed a 15 cm jumper wire isn't a simple connection. It has inductance: it resists sudden changes in current. It also has capacitance to every wire next to it. Below a few MHz you can ignore both. On fast edges they decide everything.
Ringing
The edge travels down the wire and reaches the display's input, which takes almost no current. It reflects, like a wave hitting a wall, comes back, and reflects again at the Pico's low-impedance output:
sent: ┌────── received: ┌╮ ╭─╮ ╭──────
│ │╰─╯ ╰─╯ ← ringing
───────┘ ───────┘On the clock line, a ring that dips back across the threshold counts as an extra clock pulse. Every bit after it lands in the wrong position. That's the picture that appears and then dissolves.
A 33 Ω resistor in series at the Pico fixes it. Together with the Pico's own output resistance, it roughly matches the wire, so the wave coming back is absorbed instead of bouncing again. This is called series termination.
Crosstalk
Wires running side by side couple. They form a tiny capacitor (a voltage edge pushes current into the neighbour: I = C·dV/dt) and a tiny transformer (a current edge induces voltage in it: V = M·dI/dt).
The DC line tells the display "command" (low) or "pixel" (high). It sits high for the whole frame and never moves, but it ran right beside the clock and data lines, which toggle tens of millions of times a second. Every edge nudged DC. Occasionally a nudge dipped it low at exactly the moment the display sampled it, and then one pixel byte got executed as a command:
SDA (busy film data): ─┐┌┐┌─┐┌┐┌──┐┌┐
└┘└┘ └┘└┘ └┘└
DC (should stay high): ───────────╲╱────
↑ this byte becomes a COMMANDThat explains everything that had looked so strange:
And it explains why only the film failed. The colour-bar test pattern sends just six byte values (FF E0 07 F8 1F 00), and none of them is a harmful command. Its long runs of identical colour also barely toggle the data line, so far fewer crosstalk spikes happen in the first place. Film data toggles constantly and contains every byte value, so sooner or later a glitch lands on a harmful one.
At 25 MHz each bit lasts 40 ns instead of 26.7 ns, so the ringing and spikes die down before the next sample. The noise is the same; the margin is bigger.
The final fix was physical: move the DC wire away from SCL and SDA. The negative picture never came back.
Ground is half of every signal
Every signal current returns to the Pico through ground. With one ground wire far away, signal and return form a large loop, and a large loop means more inductance and more coupling. A ground wire running right beside the clock keeps the loop small. It cost nothing and helped a lot.
The payoff: the model holds on a second chip
With the wiring fixed, I ran the paper's full method on the Pico 2:
- two windows of the film (4 s each, because the paper's 10 s clips don't fit in 4 MB of flash);
- single-core and dual-core;
- 10 runs of 720 frames per configuration, timings held in RAM so measuring doesn't disturb the run;
- everything at one recorded commit.
The result I care most about: unpacking time is still a straight line in the compressed frame size.
ESP32-S3: 4.858 ms + 0.1515 µs per byte (r² = 0.9987) RP2350: 8.108 ms + 0.2446 µs per byte (r² = 0.9984)
Each constant is about 1.6× the ESP32-S3's, which fits a 150 MHz clock against 240 MHz and a decoder in RAM instead of ROM. The model also makes a sharp prediction: on the RP2350, single-core playback could only keep up with frames under 571 bytes, while real film frames are 27–38 KB. So it predicts every frame late, and every frame was late. Dual-core hides decoding for frames up to about 103 KB, far beyond anything a 180×135 frame can be. The library's rv565 info --chip rp2350 now predicts a 49.00 ms worst frame for the first window; the board measured 49.03 ms.
One thing didn't carry over. On the ESP32-S3, using both cores cost nothing measurable. On the RP2350 they slow each other down: decoding on core 1 takes about 1.3 ms longer, and scaling on core 0 about 2.3 ms longer. Both read from the same flash through the same cache, and the likely cause is contention there. That's a lead for the next experiment, not a conclusion yet.
What I'd tell myself at the start
- A fast benchmark isn't a correct one. Look at the screen.
- Get a known-good reference first. Slow MicroPython, typed by hand, settled a question that hours of reading C couldn't.
- Change one variable per test, and make the test show its own answer. The colour-per-speed ladder and the A/B matrix did more than any amount of theorising.
- Watch out for your own tests' blind spots. The speed test passed for a reason that had nothing to do with speed.
- "Works slowly, fails fast" means signal integrity until proven otherwise. Keep fast wires short, add a 22–47 Ω series resistor at the driver, run a ground beside the clock, and keep quiet control lines away from busy ones.
- Real data finds bugs that test patterns hide. Six byte values can't exercise a bug that needs one particular byte.
- Fix the real bugs you find on the way, but don't credit them with the symptom. The stack overflow was real. It just wasn't why the screen was blank.
Links
- RV565 library: github.com/elixpo/rv565
- Full Pico 2 results and how to reproduce them:
docs/RESULTS_RP2350.md
- The paper: arXiv:2610.35935
- Wiring guide for 37.5 MHz on a breadboard:
benchmarks/rp2350_video_dma/README.md
