Hi,
I am developing some application for that I want 12 pins as interrupt mode, but I can see only 8 pins can be configured.
Can anyone suggest me please.
Thanks, and regards.
Hi,
I am developing some application for that I want 12 pins as interrupt mode, but I can see only 8 pins can be configured.
Can anyone suggest me please.
Thanks, and regards.
You need to use the PORT event instead of the IN events. Then you can use any number of GPIOs. See:
Hi haakonsh,
In my application multiple buttons are also pressed together so these situations should be considered, and as per your suggestion if i use port events then still i can configure 8 interrupts since it has only 8 config in gpiote (0-7). If you have any code for the same then please do share it with me.
Thanks and regards.
Hey Ajmal,
The PORT event does not use GPIOTE channels at all.
Call nrfx_gpiote_in_init() with an nrfx_gpiote_in_config_t struct where the hi_accuracy member is set to 'false'. The GPIOTE driver will now use the PORT event for the provided pin and its trigger config.
BR,
haakonsh.
Hi haakonsh,
I tried as per your suggestion and i found that many pins are automatically getting triggered like Pin 0,1,2,3,11,12 etc. and also I am not able to configure more than one pin for port interrupt because it is triggering NRF_BREAKPOINT_COND;
uint32_t err_code;
// Initialize GPIOTE module
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
nrf_gpio_cfg_input(PIN_NUMBER_1, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_input(PIN_NUMBER_2, NRF_GPIO_PIN_PULLUP);
NRF_P0->PIN_CNF[PIN_NUMBER_1] |= (GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos);
NRF_GPIOTE->INTENSET = (1 << PIN_NUMBER_1);
NRF_P0->PIN_CNF[PIN_NUMBER_2] |= (GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos);
NRF_GPIOTE->INTENSET = (1 << PIN_NUMBER_2);
nrfx_gpiote_in_config_t in_config;
in_config.pull = NRF_GPIOTE_POLARITY_HITOLO;
err_code = nrf_drv_gpiote_in_init(PIN_NUMBER_1, &in_config, port_event_handler);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_gpiote_in_init(PIN_NUMBER_2, &in_config, port_event_handler);
APP_ERROR_CHECK(err_code);
NVIC_EnableIRQ(GPIOTE_IRQn);
}
BR,
Ajmal
Try this:
void port_event_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
switch(pin)
{
case PIN_NUMBER_1:
// Do stuff
break;
case PIN_NUMBER_2:
// Do stuff
break;
default:
// Do nothing, not interrested in any of the other pins port events
break;
}
}
uint32_t err_code;
// Initialize GPIOTE module
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
nrfx_gpiote_in_config_t in_config;
in_config.sense = NRF_GPIOTE_POLARITY_HITOLO;
in_config.pull = NRF_GPIO_PIN_PULLUP;
in_config.is_watcher = false;
in_config.hi_accuracy = false;
in_config.skip_gpio_setup = false;
err_code = nrf_drv_gpiote_in_init(PIN_NUMBER_1, &in_config, port_event_handler);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_gpiote_in_init(PIN_NUMBER_2, &in_config, port_event_handler);
APP_ERROR_CHECK(err_code);
If you still get an error, note the file name and line number.