WeAct Blackpill STM32F411 pin.irq usage #16247
-
After many attempts to get 3 interrupt sources working reliably I was left wondering ... whether or not there was some obvious reason, The code for one sensor: def gate_interrupt(pin):
"""Gate sensor interrupt."""
global gate_flag
global cars_coming_in
global cars_going_out
global cars_in_at_gate
global cars_out_at_gate
gate_sensor.irq(None, Pin.IRQ_FALLING)
gate_flag = True
time.sleep_ms(DEBOUNCE)
if cars_coming_in is True:
cars_in_at_gate += 1
elif cars_going_out is True:
cars_out_at_gate += 1
gate_sensor.irq(gate_interrupt, Pin.IRQ_FALLING) I read somewhere that This not seem to be the case. I am aware that ISRs should be short and I am even putting I think pending interrupts are stacking-up somewhere. Any suggestions for my next attempt would be appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
AFAIK
Can you provide a link to the relevant docs/descriptions? |
Beta Was this translation helpful? Give feedback.
-
Hi Dave, you can have a look at the code below, import machine, time
from machine import Pin
from _thread import start_new_thread as task
def pin_cb(p):
global t0, t1
wait = W - time.ticks_diff(t1, t0)
if wait > 0:
print(f'Event happend, do nothing. Wait {wait} ms')
t1 = time.ticks_ms()
else:
print("hello", p, time.ticks_us())
t0 = time.ticks_ms()
touch = Pin('A0', Pin.OUT, value=0)
touch.irq(trigger=Pin.IRQ_FALLING, handler=pin_cb)
t0 = t1 = 0; more = True; W = 5000
def loop():
while more:
touch(1)
touch(0) # trigger
print('Sleep in loop'); time.sleep_ms(800)
task(loop, ()) # start loop
time.sleep(30) # keep all alive for 60 sec
print('Disable handler')
touch.irq(trigger=Pin.IRQ_FALLING, handler=None) # disable handler
time.sleep(5)
more = False
print('Bye') hopefully it helps. |
Beta Was this translation helpful? Give feedback.
-
I had this problem when I noticed that error message: I asked for help in this discussion thread and recommend reading it. |
Beta Was this translation helpful? Give feedback.
-
@rkompass informative reading. I now understand that this problem requires serious work. Thanks for the suggestions. |
Beta Was this translation helpful? Give feedback.
@davefes
I had this problem when I noticed that error message:
RuntimeError: schedule queue full
.I asked for help in this discussion thread and recommend reading it.