Why is the interrupt queued?

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
bittware
Posts: 45
Joined: Mon Aug 18, 2014 3:27 am

Why is the interrupt queued?

Post by bittware » Wed Jul 27, 2022 3:44 am

I'm using the pyboard and my interrupt comes in every 3.3ms.
The interrupt source is connected to a GPIO input.

Code: Select all

pin_int.irq(trigger=Pin.IRQ_RISING, handler=tick)
The interrupt service route is plain.

Code: Select all

def tick(int_pin):
  loop_test1.high()
  # blahblahblah
  loop_test1.low()
loop_test1 is a GPIO output connected to an oscilloscope. By watching the loop_test1, interrupt latency and ISR running time can be measured.
But to my surprise, the captured waveform does not align the interrupt event (purple line) to the loop_test1 (yellow line), except for the very first one. The interrupt events seem to be queued and responsed in batch.
How could it be like this?
Attachments
1209696846.jpg
1209696846.jpg (236.25 KiB) Viewed 23516 times

bittware
Posts: 45
Joined: Mon Aug 18, 2014 3:27 am

Re: Why is the interrupt queued?

Post by bittware » Wed Jul 27, 2022 7:14 am

After a few trials, I found the ISR seems to be scheduled implicitly even though micropython.schedule() is never explicitly called.
This is a little werid. By what standard, this kind of auto schedule is invovled?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Why is the interrupt queued?

Post by Roberthh » Wed Jul 27, 2022 9:57 am

The IRQ handler schedules the callback. If you use the option hard=True in setting up the Pin.irq, zhen the call is made immediately and not scheduled.

jim
Posts: 20
Joined: Tue Feb 23, 2021 10:22 pm

Re: Why is the interrupt queued?

Post by jim » Thu Jul 28, 2022 6:55 pm

Roberthh wrote:
Wed Jul 27, 2022 9:57 am
The IRQ handler schedules the callback. If you use the option hard=True in setting up the Pin.irq, zhen the call is made immediately and not scheduled.
What is the behavior of pyb.ExtInt(), which doesn't seem to use this option?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Why is the interrupt queued?

Post by Roberthh » Thu Jul 28, 2022 7:21 pm

pyb.Extint() the the old PyBoard only method, which is replaced by machine.pin.irq(). The latter should be available on all ports. AFAIK, pyb.Extint() runs a hard interrupt, but I never tested that.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Why is the interrupt queued?

Post by pythoncoder » Fri Jul 29, 2022 7:43 am

Roberthh wrote:
Thu Jul 28, 2022 7:21 pm
... AFAIK, pyb.Extint() runs a hard interrupt, but I never tested that.
It does. But as you point out it is effectively obsolete.
Peter Hinch
Index to my micropython libraries.

Post Reply