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
  • 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 true for GPIOTE IN channels for the nRF51-series devices.

    For nRF52-series devices, it is 8 GPIOTE IN channels:

    https://infocenter.nordicsemi.com/topic/struct_nrf52/struct/nrf52.html?cp=5

     

    That being mentioned, you can still use level triggered wakeup sources, ie. GPIOTE PORT event. This can be set on all GPIOs if you want.

    To implement a software-emulated edge-triggered detection based on GPIOTE PORT event, you can use "sense-edge-mask" in DeviceTree:

     How to use sense-edge-mask? 

     

    Kind regards,

    Håkon

  • Hi Håkon,

    Thank you for the feedback. I will look into using the "sense-edge-mask".  However, I still think gpio_pin_interrupt_configure() should return an error if you try to configure more interrupts than are available in the chip. This would have saved me a lot of time trying to figure out what was going on.

    \Eric

  • 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

Reply
  • 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

Children
Related