Reputation: 45
This code works but the interrupt only triggers when running on statemachine 0
:
Although it is working I want to know if there are other ways to solve it
from machine import Pin, PWM
from time import sleep
import rp2
class PioLoader():
@rp2.asm_pio(set_init=rp2.PIO.OUT_LOW)
def blink():
wrap_target()
set(pins, 1) [31]
nop() [31]
nop() [31]
nop() [31]
nop() [31]
set(pins, 0) [31]
nop() [31]
nop() [31]
nop() [31]
nop() [31]
irq(0)
wrap()
def irqHandler(sm):
self.sm.active(0)
print("Finished")
def __init__(self):
pass
def test(self):
sm = rp2.StateMachine(0, self.blink, freq=2000, set_base=Pin(25))
sm.irq(self.irqHandler)
print(sm)
sm.active(1)
sleep(2)
sm.active(0)
Can anyone help figuring the issue out?
Upvotes: 0
Views: 902
Reputation: 45
Found that statemachines 0 to 3 work with irq(0 to 3) and machines 4-7 need irq(0 to 3)
The solution is to use irq(rel(0)) which works in all cases. Phew!!!! Hope this helps someone else.
Upvotes: 1