IRQ between StateMachine blocks #11114
Answered
by
rkompass
andrekuehne
asked this question in
RP2040 / Pico
-
Is it possible to synchronize multiple PIO state machines that live on separate blocks using IRQs? The following code blinks an LED on GPIO0 and works when both state machines share the same block (e.g. _SM_BLINK_ID=0, _SM_IRQ_ID = 3 or _SM_BLINK_ID=4, _SM_IRQ_ID = 7 ) but fails once they live on different blocks (e.g. _SM_BLINK_ID=0, _SM_IRQ_ID = 4). Is there a potential alternative to achieve the desired behavior? Thanks! from rp2 import PIO, asm_pio, StateMachine
from machine import Pin
_IRQ_NUM = const(1)
_SM_BLINK_ID = 0
_SM_IRQ_ID = 1
@asm_pio(set_init=PIO.OUT_LOW)
def blink_on_irq():
irq(block,_IRQ_NUM)
set(pins,0b1)
irq(block,_IRQ_NUM)
set(pins,0b0)
@asm_pio()
def timed_irq():
pull(block) # get delay
mov(x,osr) # store in x
mov(y,x) # store in y
wrap_target()
irq(clear,_IRQ_NUM)
label("delay")
jmp(x_dec,"delay")
mov(x,y)
sm_blink = StateMachine(_SM_BLINK_ID,blink_on_irq,set_base=Pin(0),freq=2000)
sm_irq = StateMachine(_SM_IRQ_ID,timed_irq,freq=2000)
sm_blink.active(1)
sm_irq.active(1)
sm_irq.put(500) |
Beta Was this translation helpful? Give feedback.
Answered by
rkompass
Mar 24, 2023
Replies: 1 comment 3 replies
-
Simple answer is: No. The IRQ flags of the two PIO blocks reside in different memory areas. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
andrekuehne
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple answer is: No. The IRQ flags of the two PIO blocks reside in different memory areas.