PIO question #16725
Unanswered
jean-claudeF
asked this question in
RP2040 / Pico
PIO question
#16725
Replies: 1 comment 14 replies
-
you are trying to create/run an instruction that is not possible in the PIO so your source AFAIK there is no direct way to load a 32 bit number from code into one of the fifos you can provide a number, and have the pio echo that back ( or do something more interesting ) import time
import machine
from rp2 import PIO, StateMachine, asm_pio
# Define a PIO program
@asm_pio()
def test():
pull() # Pull a value from the TX FIFO into OSR
mov(isr, osr) # Move the value from OSR to ISR
push() # Push ISR to RX FIFO
# Initialize StateMachine with the PIO program
sm = StateMachine(0, test, freq=1_000_000)
# Load a value into the TX FIFO
input_value = 1234
sm.put(input_value)
# Activate the StateMachine
sm.active(1)
time.sleep(0.1) # Give time to execute
# Check if there is data in the RX FIFO and print it
if sm.rx_fifo() > 0:
output_value = sm.get()
print(f"Input: {input_value}, Output: {output_value}") The documentation for the pio.mov instruction is :
|
Beta Was this translation helpful? Give feedback.
14 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.
-
Hi,
can somebody explain what's wrong in this simple test program?
Beta Was this translation helpful? Give feedback.
All reactions