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

gpiote interrupt invalid

nRF51822 sdk9.0

I am having a problem with GPIOTE. I have four interrupts programmed on four different pins.

As long as the signals do not transition at the same time, the firmware receives interrupts from all pins independently; everything works fine. However, if any two signals change simultaneously, the GPIOTE seems to stop responding altogether: no further interrupts are generated.

Four of the interrupts are configured :

nrf_drv_gpiote_in_config_t config_ppr = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
config_ppr.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(PIN_CHARGE_PPR, &config_ppr, gpiote_ppr_handler);
APP_ERROR_CHECK(err_code);

nrf_drv_gpiote_in_config_t config_chr = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
config_chr.pull = NRF_GPIO_PIN_PULLUP;        
err_code = nrf_drv_gpiote_in_init(PIN_CHARGE_CHG, &config_chr, gpiote_chr_handler);
APP_ERROR_CHECK(err_code);
(#define PIN_CHARGE_CHG 28
#define PIN_CHARGE_PPR 29)

nrf_drv_gpiote_in_config_t config_ppr = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
config_ppr.sense = GPIOTE_CONFIG_POLARITY_LoToHi;
config_ppr.pull = GPIO_PIN_CNF_PULL_Pulldown;
err_code = nrf_drv_gpiote_in_init(OPT_CONFIG_EINT_PIN_NUMBER, &config_ppr, gpiote_bhi160_handler);
(OPT_CONFIG_EINT_PIN_NUMBER = 31)

nrf_drv_gpiote_in_config_t config_ppr = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
config_ppr.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(PIN_OPT_BUTTON, &config_ppr, gpiote_button_handler);
(PIN_OPT_BUTTON = 16)
  • Hi,

    That is strange. I tested your code, slightly modified to make it compile and use the correct pins on my nRF51 DK, and it seemed to work:

    void gpiote_ppr_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        nrf_gpio_pin_toggle(LED_1);
    }
    
    void gpiote_chr_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        nrf_gpio_pin_toggle(LED_2);
    }
    
    void gpiote_bhi160_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        nrf_gpio_pin_toggle(LED_3);
    }
    
    void gpiote_button_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        nrf_gpio_pin_toggle(LED_4);
    }
        
    void setup()
    {
        uint32_t err_code;
                
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
        
        nrf_drv_gpiote_in_config_t config_ppr = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
        config_ppr.pull = NRF_GPIO_PIN_PULLUP;
        err_code = nrf_drv_gpiote_in_init(BUTTON_1, &config_ppr, gpiote_ppr_handler);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_gpiote_in_config_t config_chr = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
        config_chr.pull = NRF_GPIO_PIN_PULLUP;        
        err_code = nrf_drv_gpiote_in_init(BUTTON_2, &config_chr, gpiote_chr_handler);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_gpiote_in_config_t config_ppr_1 = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
        //config_ppr_1.sense = NRF_GPIOTE_POLARITY_LOTOHI;
        config_ppr_1.pull = NRF_GPIO_PIN_PULLUP;
        err_code = nrf_drv_gpiote_in_init(BUTTON_3, &config_ppr_1, gpiote_bhi160_handler);
    
        nrf_drv_gpiote_in_config_t config_ppr_2 = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
        config_ppr_2.pull = NRF_GPIO_PIN_PULLUP;
        err_code = nrf_drv_gpiote_in_init(BUTTON_4, &config_ppr_2, gpiote_button_handler);
        
        nrf_drv_gpiote_in_event_enable(BUTTON_1, true);
        nrf_drv_gpiote_in_event_enable(BUTTON_2, true);
        nrf_drv_gpiote_in_event_enable(BUTTON_3, true);
        nrf_drv_gpiote_in_event_enable(BUTTON_4, true);
    }
    

    I tied all the buttons together and triggered them simultaneously and all interrupts fired.

Related