← index #10210PR #11390
Off-topic · high · value 1.998
QUERY · ISSUE

RP2: Make PIO EXECCTRL_STATUS_SEL settable through API

openby pigrewopened 2022-12-13updated 2023-12-21
enhancement

Please add setting EXECCTRL_STATUS_SEL to the initializer of a PIO state machine for the RP2040.

I'd imagine this would be something like:

StateMachine.init(program,...,status_sel=PIO.TX_FIFO, status_n=3)

The new initialization routine could then call sm_config_set_mov_status(...) from the pico-sdk.

Thanks!

As a workaround, for now, I'm doing something like:

import machine
import rp2
PIO0_BASE = const(0x50200000)
PIO1_BASE = 0x50300000
PIO_SM1_EXECTRL = const(0x00e4)

# Setup status flag for the SSU PIO code
ecv = machine.mem32[PIO0_BASE + PIO_SM1_EXECTRL]
ecv = (ecv & (~0x0000001F)) | 0x02 # status_sel = TX FIFO, N=3
machine.mem32[PIO0_BASE + PIO_SM1_EXECTRL] = ecv
CANDIDATE · PULL REQUEST

rp2: Make rp2_state_machine_exec accept integers.

mergedby adamgreenopened 2023-05-01updated 2023-05-18
port-rp2

Currently rp2.StateMachine.exec(instr_in) requires that the instr_in parameter be a string representing the PIO assembly language instruction to be encoded by rp2.asm_pio_encode(). This commit allows the parameter to also be of integral type. This is useful if the exec() method is being called often where the use of pre-encoded machine code is desireable.

This PR still supports calls like:

    sm.exec("set(0, 1)")

It also now supports calls like:

    # Performed once earlier, maybe in __init__()
    assembled_instr = rp2.asm_pio_encode("out(y, 8)", 0)
    # Performed multiple times later as the PIO state machine is
    # configured for its next run.
    sm.exec(assembled_instr)

I didn't find any rp2 specific tests to run or extend but I did find 2 rp2 examples (examples/rp2/pio_exec.py and examples/rp2/pio_pwm.py) that exercise the rp2.StateMachine.exec() method. I ran those 2 examples to make sure that they weren't broken by my change.

I look forward to any feedback which helps improve this PR and its suitableness for merging.

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