This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Interrupts on many pins high to low

I want to detect high to low transitions on 28 GPIO independently. I've read in other posts you can configure 4 pin interrupts or a port interrupt for all pins, but I'm not sure that allows the pins to have different states and still be detected.

I'm using GPIOTE. The code below does not seem to work for all pins.

for(int i = 2; ...; i++) {
    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
    in_config.pull = NRF_GPIO_PIN_NOPULL;
    err_code = nrf_drv_gpiote_in_init(i, &in_config, in_pin_handler);
    VERIFY_SUCCESS(err_code);
    nrf_drv_gpiote_in_event_enable(i, true);
}

Is the only solution polling?

Parents
  • Hi,

    In order to use IN event, a GPIOTE channel is required. On nRF52832 there are 8 GPIOTE channels available (4 channels on nRF51 series). Using the PORT event, you can still track individual pin states, but you need to check each enabled pin on every event, to keep track of which pin changed. This is slower than IN events, and can not be used to track high-speed pin changes. 

    If you use the GPIOTE driver in the SDK, this will track the pin states for you automatically.

    Best regards,
    Jørgen

Reply
  • Hi,

    In order to use IN event, a GPIOTE channel is required. On nRF52832 there are 8 GPIOTE channels available (4 channels on nRF51 series). Using the PORT event, you can still track individual pin states, but you need to check each enabled pin on every event, to keep track of which pin changed. This is slower than IN events, and can not be used to track high-speed pin changes. 

    If you use the GPIOTE driver in the SDK, this will track the pin states for you automatically.

    Best regards,
    Jørgen

Children
Related