I really wanted to try getting this working on my own, since interrupts are a pretty standard practice, but I just cannot figure out why my callback is not being called.
I am able to run the extint_wakeup.py example, and the interrupt does indeed wakeup the MCU. However, when I tried modifying the code a bit so set off a flag, I found the that the callback isn’t called. Im currently trying to just toggle the led in the callback to verify:
I appreciate you responding. I added that line at some point because I saw it in example code somewhere.
I commented out that line of code but there’s no change in behavior; the LED blinks periodically, but triggering the pin still does not toggle the LED between the blinking. Therefore, I assume the callback isn’t being called.
May or may not be related, but I found a different post with a similar problem but on a different board:
I updated the code to better demonstrate the issue:
import sensor, image, time, pyb, machine
from pyb import Pin, ExtInt
RED_LED_PIN = 1
GREEN_LED_PIN = 2
BLUE_LED_PIN = 3
led = pyb.LED(BLUE_LED_PIN)
flag = False
flag = True
# Attempt 1
pin = Pin("PC7", Pin.IN, Pin.PULL_UP)
ext = ExtInt(pin, ExtInt.IRQ_FALLING, Pin.PULL_UP, callback)
#pin = machine.Pin("PC7", machine.Pin.IN, machine.Pin.PULL_UP)
flag = False
for i in range(1,10):
Asserting ground on pin PC7 does wake up the Portenta, the LED toggles. However, the flag should also have been set to ‘True’, so I also expected the led to toggle quickly in the for loop. However, that never happens.
So it seems the the IRQ is setup correctly and the pin is accepting falling edge assertions that wake the device up, but the callback is not being called at all.