Page 1 of 1

GPIO pin kept low after falling edge?

Posted: Sat Jun 28, 2014 10:59 am
by muckypup
I am a beginner at electronics, so having difficulty and don't understand what I am doing wrong.

I have an MCP23017 which I am programming via i2c. This I am having no issue with. I have configured pin 1 on Bank B as an input and set up the registers to enable the interrupt pin. With a switch connected to the input pin of the port expander and an LED connected to the interrupt pin I can clearly see INTB as high until I press the switch. Reading from INTCAP resets the interrupt an d everyhing is fine.

So I connected the INTB pin of the port expander to pin 22 of the PI, and enabled this as input with the resister set to pull up (as the default state of INTB seems to be high). So when I press the button, INTB goes low and my script detects this correctly on the falling edge and reads from INTCAP to reset the register, however it never does reset and the LED connected to INTB is always off showing that it is still grounded. Pulling the wire from pin 22 if the PI, immediately INTB is high again (the LED is lit) showing that the read from INTCAP did indeed reset the interrupt.

Seems like after the pi has detected the falling edge, it is somehow keeping pin 22 to INTB grounded.

Anyone have any ideas? (Sorry for the long winded post)

Steve

Re: GPIO pin kept low after falling edge?

Posted: Sat Jun 28, 2014 11:18 am
by joan
First thing I'd try is removing pull-up/downs from gpio 22. Let it be driven solely by the interrupt pin.

Re: GPIO pin kept low after falling edge?

Posted: Sat Jun 28, 2014 11:34 am
by muckypup
Tried that - Does the same.

Steve

Re: GPIO pin kept low after falling edge?

Posted: Sat Jun 28, 2014 11:46 am
by joan
Probably best if you post some photos of your set-up as well as the code you are using.

Re: GPIO pin kept low after falling edge?

Posted: Sat Jun 28, 2014 12:11 pm
by muckypup
The board is here...

Image

The simplified code here...

def my_callback(channel):
ic2bus.read_byte_data(address, 0x11])

GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.IN)
GPIO.add_event_detect(25, GPIO.FALLING, callback=my_callback, bouncetime=300)

while True:
for MyData in range(1,256):
... write byte to i2c output pins

Re: GPIO pin kept low after falling edge?

Posted: Sat Jun 28, 2014 12:12 pm
by muckypup

Re: GPIO pin kept low after falling edge?

Posted: Sat Jun 28, 2014 12:15 pm
by muckypup
Interrupts are set up using..

i2cbus.write_byte_data(i2cAddress, registers['GPINTENB'], 0x1)
i2cbus.write_byte_data(i2cAddress, registers['DEFVALB'], 0x1)
i2cbus.write_byte_data(i2cAddress, registers['INTCONB'], 0x00)

S.