S3 Pin IRQ interrupt handler

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
stephanelsmith
Posts: 9
Joined: Mon Oct 18, 2021 7:03 pm

S3 Pin IRQ interrupt handler

Post by stephanelsmith » Tue Apr 05, 2022 2:03 am

Having an interesting issue, I'm wondering if it's just me or if anyone out there with an S3 can reproduce. I've created an issue report for it:
https://github.com/micropython/micropython/issues/8488

Brief, in S2 (and previous versions), I have no problem with pin irqs. Now that I'm working through S3 kinks, the IRQ handler on S3 seems to not be called. This is on firmware built with esp-idf v4.4 and micropython master.

Code: Select all

from machine import Pin
p = Pin(5, Pin.IN, pull=Pin.PULL_DOWN)
p.irq(lambda pin:print(pin))
I've dug through the code a bit, and have been able to tease anything out. It feels like if this in fact an issue, it would be something like a #define missing for S3 port.

Shards
Posts: 39
Joined: Fri Jun 25, 2021 5:14 pm
Location: Milton Keynes, UK

Re: S3 Pin IRQ interrupt handler

Post by Shards » Tue Apr 05, 2022 9:54 am

Works for me:

Code: Select all

from machine import Pin
p = Pin(5,Pin.IN,pull=Pin.PULL_DOWN)
p.irq(lambda pin:print(pin))
Briefly connecting pin 5 to 3.3v results in a stream of Pin(5)s being printed. And change it to Pin.PULL_UP and grounding pin 5 works too.

I'm using an Unexpected Maker(UM) Feather S3 board. The Micropython build I'm using is the one from the UM GitHub repo: https://github.com/UnexpectedMaker/esp3 ... n/Firmware. This is still the Micropython build recommended to use on the UM website.

I've just tried flashing latest build from Micropython download area for the UM Feather S3 and the interrupt now doesn't work. Hopefully the raised issue will address the problem. And it's working again when I revert to the UM build.

stephanelsmith
Posts: 9
Joined: Mon Oct 18, 2021 7:03 pm

Re: S3 Pin IRQ interrupt handler

Post by stephanelsmith » Tue Apr 05, 2022 3:08 pm

Confirming that pin.irq is working on UM ProS3 firmware, but not master.

This gives me a bunch of clues to track this one down. I'll see if I can narrow it down to the specific commit where the functionality changed.

Thank you so much for giving it a go and for the additional information. I'll do my part and keep tackling all things s3.

stephanelsmith
Posts: 9
Joined: Mon Oct 18, 2021 7:03 pm

Re: S3 Pin IRQ interrupt handler

Post by stephanelsmith » Wed Apr 06, 2022 8:42 pm

Following up on my own issue
https://github.com/micropython/micropython/issues/8488

The issue first appears on this commit:
3570785 esp32: Pin MicroPython to core 1 again.
Previous commits work correctly on S3.

That may explain different in S2/S3 as they have single/dual cores respectively. I don't fully understand the dual core nature and how micropython is interacting with this, much less, how it affects pin.irq handler.

I'll keep researching. Any guidance on mutli-core/micropython, would be appreciated!

Post Reply