Reading of multiple GPIO does not work

Hello,

we developed a application on the nRF52840DK as a central device. Now we need to add four GPIO as inputs for reading the edges of four signals. Our problem is, that only two of the four GPIO inputs are working. The handler of the other two pins never get triggered.

Here is the relevant code:

 

#define PIN_BNC_IN1_RISE        26 
#define PIN_BNC_IN1_FALL        27 

#define PIN_BNC_IN2_RISE        28 
#define PIN_BNC_IN2_FALL        4   


/**
 * @brief Function for handling the GPIO interrupt on PIN_BNC_IN1_RISE
 */
void pin_BNCIN1_handler_rise(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    // Action 1
}

/**
 * @brief Function for handling the GPIO interrupt on PIN_BNC_IN1_FALL
 */
void pin_BNCIN1_handler_fall(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    // Action 2
}

/**
 * @brief Function for handling the GPIO interrupt on PIN_BNC_IN2_RISE
 */
void pin_BNCIN2_handler_rise(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    // Action 3
}

/**
 * @brief Function for handling the GPIO interrupt on PIN_BNC_IN2_FALL
 */
void pin_BNCIN2_handler_fall(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    // Action 4
}


/**
 * @brief Function for configuring the PIN_BNC_IN1_RISE (rising edge)
 */
static void gpio_BNC1_init_rise(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    in_config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(PIN_BNC_IN1_RISE, &in_config, pin_BNCIN1_handler_rise);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_BNC_IN1_RISE, true);

    NVIC_EnableIRQ(GPIOTE_IRQn);
    NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_LOW);
}

/**
 * @brief Function for configuring: PIN_BNC_IN1_FALL (falling edge)
 */
static void gpio_BNC1_init_fall(void)
{
    ret_code_t err_code;

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
    in_config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(PIN_BNC_IN1_FALL, &in_config, pin_BNCIN1_handler_fall);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_BNC_IN1_FALL, true);

    NVIC_EnableIRQ(GPIOTE_IRQn);
    NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_LOW);
}

/**
 * @brief Function for configuring the PIN_BNC_IN2_RISE (rising edge)
 */
static void gpio_BNC2_init_rise(void)
{
    ret_code_t err_code;

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    in_config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(PIN_BNC_IN2_RISE, &in_config, pin_BNCIN2_handler_rise);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_BNC_IN2_RISE, true);

    NVIC_EnableIRQ(GPIOTE_IRQn);
    NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_LOW);
}

/**
 * @brief Function for configuring the PIN_BNC_IN2_FALL (rising edge)
 */
static void gpio_BNC2_init_fall(void)
{
    ret_code_t err_code;

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
    in_config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(PIN_BNC_IN2_FALL, &in_config, pin_BNCIN2_handler_fall);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_BNC_IN2_FALL, true);

    NVIC_EnableIRQ(GPIOTE_IRQn);
    NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_LOW);
}

void gpio_BNC_init(void){
    gpio_BNC1_init_rise();
    gpio_BNC1_init_fall();
    gpio_BNC2_init_rise();
    gpio_BNC2_init_fall();
}

int main(void)
{
    gpio_BNC_init();
    ...
}

Only Action 1 and Action 2 gets triggered and executed. Action 3 and Action 4 get never triggered. Even when applying the same signal to all four pins.

I already tried to change GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS to a higher value. But it still does not work.

What is the reason for this?

Thank you very much in advance. Any kind of feedback is always appreciated.

Best regards,

Michael

Related