Tutorials
Will the RP2040 PIO RX FIFO Hold a Burst Until DMA Can Read It?
Published · Updated
A logic capture can have the correct bit rate and still have holes. The state machine may pause on a full receive FIFO while the external source continues to change.
Convert incoming bits to the words the state machine pushes

Inspect the shift direction, autopush threshold and whether an explicit PUSH can block. A default PIO state-machine RX FIFO holds four 32-bit words. A receive-only design can join the FIFOs to gain eight receive entries, at the expense of its transmit FIFO.
Counting bytes on the wire gives the wrong storage budget when the packing threshold differs from eight. Use the actual packing and account for any words already waiting.
Budget FIFO capacity during a service stall · Capture the first rejected FIFO write
Budget an 800 kbit/s stream packed into 32-bit words

At 800,000 bits per second and 32 bits per pushed word, one word arrives every 40 µs. Four initially empty slots represent 160 µs of incoming data. With eight empty slots the interval is 320 µs.
These are storage intervals rather than a guaranteed maximum interrupt duration: partially collected words, FIFO occupancy and DMA arbitration change the margin. If the input has no backpressure, any PIO stall may invalidate the time continuity of the capture even if no error bit accompanies the data.
What test reveals a stalled capture if every stored word looks plausible?
Feed a known sequence with an independent time reference. Check sequence continuity and expected elapsed time over a whole block, then repeat while generating the longest expected competing DMA activity.
Replay the worked example

- Default, four words · 32 bits/word · 160 µs
- Joined, eight words · 32 bits/word · 320 µs
- Two free words · 40 µs/word · 80 µs
Compare ring and ping-pong buffering · Work through a sensor FIFO watermark
Bound queue growth during a storage stall.
Raspberry Pi RP2040 Datasheet, chapter 3, Programmable I/O.
Photograph credit and licence
Dilshan Jayakody from Maharagama, Sri Lanka (Wikimedia Commons), CC BY-SA 2.0. Site-sized copy.
Original photograph https://commons.wikimedia.org/wiki/File:8_Channel_USB_logic_analyzer_(5172098012).jpg
Licence https://creativecommons.org/licenses/by-sa/2.0
Back to Tutorials