pigpio icon indicating copy to clipboard operation
pigpio copied to clipboard

gpioSetISRFuncEx does not trigger on rpi3/4

Open folkertvanheusden opened this issue 2 years ago • 2 comments

Hi,

When making GPIO 2 high, the callback is not triggered on rpi4 (I've verified that it works fine on rpi2).

#include <pigpio.h>
#include <stdio.h>
#include <unistd.h>

void func(int gpio_n, int level, uint32_t tick, void *modemptr)
{
	printf("%d %d %d\n", gpio_n, level, tick);
}

int main(int argc, char *argv[])
{
        int gpio_n = 2;
        gpioInitialise();
    gpioSetMode(gpio_n, PI_INPUT);
    gpioSetISRFuncEx(gpio_n, FALLING_EDGE, 10000, func, NULL);

    for(;;)
	    sleep(86400);

    return 0;
}

If I replace sleep() with printf("%d\n", gpioRead(gpio_n)), then I do see the pin go from 1 to 0, yet no trigger.

folkertvanheusden avatar Sep 01 '22 06:09 folkertvanheusden

The ISR function uses the Linux sysfs system to provide interrupts.

I wonder if GPIO 2 has been already assigned for another purpose (e.g. I2C) and is not available to be used.

Check to see if /dev/i2c-1 exists.

Also check that the return from gpioSetISRFuncEx is not an error code.

joan2937 avatar Sep 05 '22 21:09 joan2937

Hi,

No I2C configured and gpioSetISRFuncEx returned no error (0).

There's progress though: if I make sure that the device resets (makes low) its irq-pin and then set the isr-function, then it works.

folkertvanheusden avatar Sep 08 '22 18:09 folkertvanheusden