The micropython PIO documentation is, as has been stated before, not complete yet.
I'm just a python newbie, so trying to discern the arguments of each function from the c source code while fighting with my first assembly is less than ideal for me. The coordination between CPU code and PIO code without blocking is hard to grasp right now.
I've started writing something that's maybe too hard to begin with and failing miserably, so I said: let's try the basics first... can you even output the same signal that you're reading?
The answers is... sort of. But why is it inverted?
Here's the code:
Code: Select all
from machine import Pin
import rp2
sm_freq = 1_000_000
sm_nr = 0
@rp2.asm_pio(
set_init=rp2.PIO.IN_HIGH,
sideset_init = rp2.PIO.OUT_HIGH,
)
def mimic():
wrap_target()
wait(1, pin, 0).side(1)
wait(0, pin, 0).side(0)
wrap()
pininput = Pin(5,Pin.IN,Pin.PULL_UP)
pinside = Pin(15,Pin.OUT)
smtest = rp2.StateMachine(
sm_nr,
prog = mimic,
freq = sm_freq,
in_base = pininput,
set_base = pininput,
jmp_pin = pininput,
sideset_base = pinside
)
smtest.active(1)
https://imgur.com/a/34gkGYB
I've played with different polarities of set_init and sideset_init and it doesn't change the result. Where is my mistake?