← index #17747PR #18975
Related · high · value 6.041
QUERY · ISSUE

rp2: Support for new RP2350 PIO instructions in the `@rp2.asm_pio` assembler

openby rtyleyopened 2025-07-22updated 2025-12-30
enhancementport-rp2

Description

The RP2350 adds several new PIO instructions/options compared to the RP2040 - currently they're not supported by MicroPython's @rp2.asm_pio assembler, so it's difficult to use them under MicroPython.

https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf

The PIO changes are listed in Section 11.1.1. ('Changes from RP2040') - note that the first change is:

DBG_CFGINFO.VERSION indicates the PIO version, to allow PIO feature detection at runtime.
This 4-bit field was reserved-0 on RP2040 (indicating version 0), and reads as 1 on RP2350.

Specifically I'm interested in the new variants of mov that allow random-access to the FIFO queue with indexed arguments:

  • mov rxfifo[y], isr
  • mov rxfifo[<index>], isr
  • mov osr, rxfifo[y]
  • mov osr, rxfifo[<index>]

where:

  • y : The literal token "y", indicating the RX FIFO entry is indexed by the Y register.
  • <index> : A value (see Section 11.3.2) specifying the RX FIFO entry to write (valid range 0-3).

It's not currently possible to express these with the Micropython mov() assembler function, so far as I'm aware.

Support for the rp2040 was originally added to MicroPython with:

  • https://github.com/micropython/micropython/pull/6791

See also:

  • https://github.com/raspberrypi/pico-feedback/issues/437

Code Size

Random-access to the FIFO queue is a pretty substantial upgrade for PIO! I really do not know how large/difficult the implementation would be though.

Implementation

I hope the MicroPython maintainers or community will implement this feature

Code of Conduct

Yes, I agree

CANDIDATE · PULL REQUEST

rp2: Add RP2350 PIO v1 assembler support.

openby bikeNomadopened 2026-03-21updated 2026-03-22
port-rp2

Add support for new PIO v1 instruction features on RP2350:

  • wait: add jmp_pin source (PINCTRL_JMP_PIN, src=3) with a
    2-bit offset argument.
  • irq: add next_pio/prev_pio index modifiers for cross-PIO IRQ
    targeting.
  • asm_pio: add in_count parameter encoding SHIFTCTRL.IN_COUNT
    (bits [4:0]) to mask unneeded IN-mapped pins to zero.
  • asm_pio: fix fifo_join encoding to support RP2350 TXGET(4),
    TXPUT(8) and PUTGET(12) modes via SHIFTCTRL bits [15:14].

All changes are backward-compatible with RP2040 PIO v0.

Also update RP2 docs to cover new changes.

Signed-off-by: NED KONZ NED@METAMAGIX.TECH

Summary

The RP2350 added a number of improvements to the PIO hardware in the RP2040.

This PR is the first of three that will bring MicroPython's RP2 PIO support up to date.

Testing

Tested on a RPI_PICO2 board using #18974: all encoding tests passed,
covering new instructions, RP2350 FIFO join modes, in_count,
and regression checks for all existing instruction encodings.

I also tested on a RPI_PICO board and there were no regressions.

Generative AI

I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied