Simple IRQ demo on your site: but what am I doing wrong ?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
rudydevolder
Posts: 3
Joined: Mon May 05, 2014 9:11 am

Simple IRQ demo on your site: but what am I doing wrong ?

Post by rudydevolder » Mon May 05, 2014 9:20 am

#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? :oops:

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Simple IRQ demo on your site: but what am I doing wrong

Post by dhylands » Mon May 05, 2014 4:09 pm

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:

Code: Select all

IRQ called :  11
IRQ called :  11
Please do note that mechanical switches may bounce, so it is possible to get multiple rising/falling edges.

rudydevolder
Posts: 3
Joined: Mon May 05, 2014 9:11 am

Re: Simple IRQ demo on your site: but what am I doing wrong

Post by rudydevolder » Tue May 06, 2014 9:14 am

Thanks Dhylan, it's working great now ! :D

Post Reply