Page 1 of 1
Simple IRQ demo on your site: but what am I doing wrong ?
Posted: Mon May 05, 2014 9:20 am
by rudydevolder
#Test not yet debounced:
def callback1(line):
print("IRQ called : ", line)
pin = pyb.Pin.board.X8
extint = pyb.ExtInt(pin, pyb.Extint.IRQFALLING, pyb.GPIO.PULL_UP, callback1)
------------------------------------------------------------------------------
Took the sample of the website but this doesn't work, got syntax-error on the print instruction?
Re: Simple IRQ demo on your site: but what am I doing wrong
Posted: Mon May 05, 2014 4:09 pm
by dhylands
There appears to be a documentation error. I was able to get this to work:
Code: Select all
Micro Python build 1f85d62-dirty on 2014-05-01; NetduinoPlus2 with STM32F405RG
Type "help()" for more information.
>>> def callback1(line):
... print("IRQ called : ", line)
...
>>> pin = pyb.Pin.board.SW
>>> extint = pyb.ExtInt(pin, pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, callback1)
>>>
The PULL_UP constant is now from the Pin module, so use pyb.Pin.PULL_UP rather then pyb.GPIO.PULL_UP (that's the documentation error).
There was also a typo in your post (you posted Extint.IRQFALLING, where ExtInt.IRQ_FALLING is correct (so ExtInt instead of Extint and the undescore between IRQ and FALLING).
I had to use SW since my pyboard hasn't arrived yet, so I tested with the onboard switch on my netduino board.
Then when I released the switch (on the netduino pushing the switch brings the line high and releasing the switch makes it go low), I see:
Please do note that mechanical switches may bounce, so it is possible to get multiple rising/falling edges.
Re: Simple IRQ demo on your site: but what am I doing wrong
Posted: Tue May 06, 2014 9:14 am
by rudydevolder
Thanks Dhylan, it's working great now !