I have an input connected to P0.18 on my nRF52832, which needs to be driven high by an external source. I am running into two problems, which may or may not be related:
1) If I configure it as follows, with either NRF_GPIO_PIN_NOPULL or NRF_GPIO_PIN_PULLDOWN, and then drive that input high, a large amount of current passes through the pin, and the device resets due to low supply voltage. Here is that configuration:
nrf_drv_gpiote_in_config_t trigger_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(false); trigger_config.pull = NRF_GPIO_PIN_NOPULL; err_code = nrf_drv_gpiote_in_init(TRIGGER_INTERRUPT_PIN, &trigger_config, in_pin_handler); APP_ERROR_CHECK(err_code); nrf_drv_gpiote_in_event_enable(TRIGGER_INTERRUPT_PIN, true); APP_ERROR_CHECK(err_code);
2) I want to use a handler for this ("B") and a second input ("A"). If I configure P0.18 with a pull-up, and then drive it low (by shorting the pin to ground), there's no reset. However an interrupt on B will make the gpiote miss the next interrupt on A, i.e. the interrupt will not be called when A goes from low to high. Here is that configuration, along with the handler:
static void gpio_init(){ ret_code_t err_code; err_code = nrf_drv_gpiote_init(); nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false); in_config.pull = NRF_GPIO_PIN_NOPULL; err_code = nrf_drv_gpiote_in_init(GYRO_INTERRUPT_PIN, &in_config, in_pin_handler); APP_ERROR_CHECK(err_code); nrf_drv_gpiote_in_config_t trigger_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(false); trigger_config.pull = NRF_GPIO_PIN_NOPULL; err_code = nrf_drv_gpiote_in_init(TRIGGER_INTERRUPT_PIN, &trigger_config, in_pin_handler); APP_ERROR_CHECK(err_code); nrf_drv_gpiote_in_event_enable(TRIGGER_INTERRUPT_PIN, true); APP_ERROR_CHECK(err_code); } void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action){ //ret_code_t ret_code = NRF_SUCCESS; if(pin == GYRO_INTERRUPT_PIN){ if(action == NRF_GPIOTE_POLARITY_LOTOHI){ //read_gyro_fifo(); //printf("Low -> High!\r\n"); task_flags |= (1<<TASK_POLL_GYRO); }else if(NRF_GPIOTE_POLARITY_HITOLO){ //printf("High -> Low!\r\n"); }else{ //printf("Toggle!\r\n"); } }else{ printf("t\r\n"); } }
So I have two questions:
- Is there something special about P0.18? I haven't run into any of these types of issues on other gpio pins.
- Is it possible for the gpiote library from the SDK to somehow miss one pin changing while it's running the handler for another pin?
EDIT: If I configure the pin just as a plain input, without GPIOTE, and poll it, I see the same problems as in #1 above--if it's configured with a pull-up, it's fine, but if it has a pull-down or NOPULL, it resets when driven high.
EDIT #2: I believe I have resolved issue #1. Should I post the second issue separately?