Raspberry Pico GPIO latency

Fyi. Writing Pico PIO code. A read from a GPIO takes…3.5 clock cycles. I think. (Plz no sue.) I tested several wildly different clock speeds. You can do INPUT_SYNC_BYPASS with `hw_set_bits(&PIO->input_sync_bypass, 1u << PIN);` and it goes down to like 1.1 cycles, but the docs warn the PIO could summon nasal demons if it reads the pin during a transition. I didn’t have any visible problems with it for the N billion samples I ran through it (though I only looked at N dozen), so maybe you’ll be fine.

I think the following, without sync bypass, was:

.wrap_target
    mov pins, pins   side 0b10
    mov pins, pins   side 0b11
    mov pins, pins   side 0b00
    mov pins, pins   side 0b01
.wrap

And with bypass:

I picked out the images that looked right, from dozens of screenshots, though, so no promises.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.