Cornell University ECE4760
Real time PIO control

Pi Pico RP2040

The PIO subsystem
The rp2040 has two dedicated I/O processors (PIO) each of which run a striped-down, single cycle, deterministic, assembly language from only 32 words of instruction memory per processor. While this is enough to generate serial protocols, including VGA at 25 million output values/sec, we begin to wonder if it is possible to swap memory on a running PIO in a seamless fashion. This means that memory modifed on-the-fly must not be executed while the program swap is being made, and that the swap is fast enough to not change the deterministic behavior of the PIO.

The DMA subsystem is fast and reasonably deterministic. It can quickly respond to signals from the PIO machines, load code, and reset signal state (clear a PIO input FIFO). As a proof of concept, swapping back and forth between two, two-instruction, program fragments was the simplest scenario I could think of that was testable. Doing the swap and handling the handshaking required chaining most of the DMA channels on the chip. This is clearly not a feasible solution. The DMAcpu machine uses three channels as a general prupose cpu which executes by chaining an arbitrarily long array of DMA control blocks through one physical DMA channel. There is, of course, fetch overhead, but the system is still fairly fast and deterministic. The resulting scheme included:

The following image shows the fixed reference pulse on the lower trace and the overlayed long/short pulses on the top trace.

Code, ZIP of project, PIO code

 


 


Copyright Cornell University April 24, 2024