Maximum number of pin interrupts

Hi,

In this post  Maximum number of interrupt enabled pins? Hung Bui states that there can only be "maximum 4 pin events, each for one GPIO pin (so max 4 pins at a time)". This is (apperently) not true since I have 8 pins set up with individual interrupt callbacks and that works just fine. This makes sense to me as there are 8 GPIOTE->CONFIG[] registers.

Consequently, adding a 9th input causes strange behaviour.But when the 9th input is configured via a call to  gpio_pin_interrupt_configure() this function does not return an error. Shouldn't this be considered a bug in the library function ?

\Eric

Parents Reply Children
  • Hi Eric,

     

    I ran a test, where I added this loop to the zephyr/samples/basic/button:

    	struct gpio_dt_spec test = {
    		.port = button.port,
    		.pin = 0,
    		.dt_flags = button.dt_flags,
    	};
    	for (int i = 0; i < 10; i++) {
    		test.pin = i;
    		ret = gpio_pin_interrupt_configure_dt(&test,
    							GPIO_INT_EDGE_TO_ACTIVE);
    		if (ret != 0) {
    			printk("Error %d: failed to configure interrupt on %s pin %d\n",
    				ret, test.port->name, test.pin);
    			return 0;
    		} else {
    			printk("Success: %d\n", i);
    		}
    	}
     

    This now shows:

    *** Booting nRF Connect SDK v2.5.0 ***
    Success: 0
    Success: 1
    Success: 2
    Success: 3
    Success: 4
    Success: 5
    Success: 6
    Success: 7
    Error -12: failed to configure interrupt on gpio@842500 pin 8
    

     

    However, If I add the below mentioned "sense-edge-mask", I can configure more than 8:

    *** Booting nRF Connect SDK v2.5.0 ***
    Success: 0
    Success: 1
    Success: 2
    Success: 3
    Success: 4
    Success: 5
    Success: 6
    Success: 7
    Success: 8
    Success: 9
    Set up button at gpio@842500 pin 6
    Set up LED at gpio@842500 pin 2
    Press the button
    

     

    Are you certain that the "sense-edge-mask" is not configured in your overlay?

     

    Kind regards,

    Håkon

  • This is my configuration:

    &gpio0 {
        status = "okay";
    };
    i.e no "sense-edge-mask = < 0x... >;" definition.
    My (inherited) code uses  gpio_pin_interrupt_configure(). Maybe gpio_pin_interrupt_configure_dt() works differently ?
  • Hi,

     

    It wraps around the function that you're using:

    https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1-1/include/zephyr/drivers/gpio.h#L931

     

    If you call the above with a GPIO_INT_EDGE* input, it will become GPIOTE allocated channel (unless it is masked in sense-edge-mask).

    A GPIO_INT_LEVEL* input will become a GPIOTE PORT event, where you can have as many as you have GPIOs available.

     

    Kind regards,

    Håkon

Related