FIFO driven PIO vs bitstream, what's best for accurate transmission of fixed and high rate protocols? #18529
Unanswered
kevinjwalters
asked this question in
RP2040 / Pico
Replies: 1 comment 2 replies
-
What makes you think that there's no DMA available for the PIOs? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The default timings for the neopixel library in MicroPython on the rp2 port are very close to the boundaries for practical timings for some RGB LED pixels. The discussion in #18295 raised the choice of two implementations:
for implementing the WS2812B wire protocol, for latter Get Started with MicroPython on Raspberry Pi Pico's PIO_WS2812.py is one example. Simplistically the PIO option gives perfect timing at up to CPU clock frequency resolution but I think this is more complex as there's no DMA here and the majority of uses would require data being fed into the PIO code via the FIFO. As the data rate increases this becomes increasingly likely to be interrupted with the stall likely to cause problems for many protocols, the WS2812B is a prime example.
For MicroPython I haven't yet dived into what
mp_hal_quiet_timing_enter()does and whatmp_event_handle_nowait()can do on therp2port which appear in the implementations. Does anyone have experience of this to be able to pinpoint the risks for the two approaches from interrupts and background tasks, e.g. packets arriving over WiFi, data arriving on USB serial, etc? For (GRB) WS2812B a 4 word FIFO would have 4 * 24 = 96 bits of data in it equating to 120us at 800 kilobaud protocol meaning anything that runs must complete comfortably within that small time window. For this unidirectional protocol the FIFOs could be "joined" to give 8 words.MicroPython's bitstream implementation
The bitstream implementation
mp_hal_quiet_timing_enter()andmp_hal_quiet_timing_exit()to perhaps tame interrupts in some way.RP2030/RP2350 PIO implementation (using FIFO)
The MicroPython StateMachine implementation
pio_sm_put()til it's fullmp_event_handle_nowait()if FIFO is fullBeta Was this translation helpful? Give feedback.
All reactions