I'm at my wits end with this one.

Okay, so we've got an MCP23017 with its INTA wired to the Pi gpio12 (bcm) in /boot/config.txt


so far so good. I'm looking to detect an event on gpio502 so, I've exported gpio502, direction in, edge both I've also exported gpio12, direction in

If I look in /proc/interrupts I can see that the interrupts are being seen at the kernel level:

160:          4  pinctrl-bcm2835  12 Level     1-0020
168:          4  gpio-mcp23xxx   6 Edge      gpiolib

The interrupts increment whenever I trigger pin 502

160:         10  pinctrl-bcm2835  12 Level     1-0020
168:         10  gpio-mcp23xxx   6 Edge      gpiolib

So far so good..... Looks like everything should be working. Here is my code to capture the event in Python

import RPi.GPIO as GPIO
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def getDigit():      #Callback when interrupt goes low
        print "received interrupt"

GPIO.add_event_detect(12, GPIO.BOTH, callback=getDigit, bouncetime=100)

Can anyone.... PLEASE..... tell me why my event detect is not seeing the interrupt.... It never gets set to the callback.... I'm at a complete loss.... I've researched for DAYS. The only conclusion I've possibly reached is, I notice that in /proc/interrupts, its listing gpio12 as level instead of edge.... but with the mcp23017 overlay loaded, I'm locked out of changing it.... the driver defaults to level and won't let me change it.

I'm new to coding python.... so I'm not sure if I'm just missing something really stupid and painfully obvious, or what..... Any assistance or guidance would be greatly greatly appreciated.

  • Is there a reason you want to use interrupts? I use DougieLawson's pincontrol.py code raspberrypi.org/forums/viewtopic.php?t=97885#p682007 – CoderMike Mar 11 at 22:49
  • I wonder if the add event detect works? I guess the kernel has reserved GPIO 12 and may not permit add event detect to claim the GPIO. – joan Mar 11 at 22:53
  • Don't know the answer but bouncetime is pointless on an interrupt line, and may interfere with interrupt. (bouncetime is only useful with mechanical contacts which may bounce) – Milliways Mar 11 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.