I wanted to implement a tachometer by decrementing X until a pin goes HIGH. I thought I could get the X value out by just moving X into ISR then pushing it. As below:.....
Frequency in statemachine doesnt matter and other values I have left at defaults which I think should be OK.
I have used sm.exec so I can try lots of different values.
Code: Select all
import rp2
code]@rp2.asm_pio()
def prog():
# set(x,63)
mov(isr,x)
push()
sm = rp2.StateMachine(0, prog, freq=4000)
sm.active(1)
for a in range(50):
sm.exec("set(x,%s)" % a)
print (sm.get())
sm.active(0)
0
1
2
...
29
30
31
0
1
...
10
11
12
It seems that only the 5 least significant digits are being returned?
What I have done wrong?