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

Eight-channel USB logic analyser. For a digital timing capture, check the analyser sample rate, input threshold and the ground path for the signal in question.
Eight-channel USB logic analyser. For a digital timing capture, check the analyser sample rate, input threshold and the ground path for the signal in question. Dilshan Jayakody from Maharagama, Sri Lanka (Wikimedia Commons), CC BY-SA 2.0. Site-sized copy.

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

Default, four words / 32 bits/word / 160 µs; Joined, eight words / 32 bits/word / 320 µs; Two free words / 40 µs/word / 80 µs
RX configuration / Packing / Empty-FIFO coverage.

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 exampleDefault, four words / 32 bits/word / 160 µs; Joined, eight words / 32 bits/word / 320 µs; Two free words / 40 µs/word / 80 µs
  1. Default, four words · 32 bits/word · 160 µs
  2. Joined, eight words · 32 bits/word · 320 µs
  3. 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

Related evidence and next tasks

Continue the task with the relevant source scope. These reading paths do not establish interchangeability or current supply.

Source addresses and citation trail

Full source addresses are retained below. Read each citation with its document revision, page, table and applicability conditions above.

  1. https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf#page=304