Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Problem with interrupt

754 Views - Created 22/04/2021


Posted by:

warg Avatar

We're trying to get A1 or B1 to go HIGH with an HIGH input on any pin but we get nothing..A1 stays high the entire time uppon launch. can anyone tell us what we're doing wrong? We have confirmed that the GPIO pin4 event is working properly. Tnx

void iopiinterrupt(){
printf("interrupt called \n");

int main(int argc, char **argv)
int pi = pigpio_start("localhost", "8888");
set_mode(pi, 4, PI_INPUT);
set_pull_up_down(pi, 4, PI_PUD_DOWN);
callback(pi,4, RISING_EDGE, iopiinterrupt);

IOPi_init(0x21, 1); // initialise one of the io pi buses on i2c address 0x20
set_port_pullups( 0x21, 0, 0x00); //turn off the internal 100K pull-up resistors for the selected IO port
set_port_direction(0x21, 0, 0xFF); // set the direction for bank 0 to be inputs

invert_port(0x21, 0, 0x00); //set the polarity of the pins on the port to be normal
set_interrupt_polarity(0x21, 1); // Set the polarity of the interrupt pin to go high.
mirror_interrupts( 0x21, 1); // Set the interrupt pins to be mirrored or for separate ports

set_interrupt_defaults( 0x21, 0, 0x00); // Set the default value to be off for all pins
set_interrupt_type( 0x21, 0, 0xFF); // Sets the type of interrupt to trigger when the pin matches the default value
set_interrupt_on_port( 0x21, 0, 0xFF); // Enable interrupts for all pins on port 0
reset_interrupts( 0x21);

while (1){}
return 0;


Posted by:

andrew Avatar

United Kingdom

andrew Twitter  andrew Website  

I tried running your code on my IO Pi Plus and the interrupt pins IA and IB are 0V until one of the inputs is pulled high.

One problem I can see with your code is the iopiinterrupt() function does not reset the IO Pi interrupts when it is triggered so the IA and IB pins will stay high after they have been triggered once. Try changing the function to the following code and see if the interrupts behave properly.

void iopiinterrupt(){
    printf("interrupt called \n");
    reset_interrupts( 0x21);

If you still have problems check that your inputs have pull-down resistors to keep them low. If you have inputs attached, for example, a button, that does not pull down to ground when it is off the input will be left in a floating state which could cause the interrupts to trigger randomly if any interference or capacitance on the cable pulls the voltage high enough for the IO chip to see it as a high input.

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.