Hello, in my project i simultaneously use MPR121 touch sensor controller and GPS module connected to UART0 of nRF52840 (custom board). To handle touch events, i use MPR121 IRQ line which is hooked up to GPIOTE pin IRQ:
void touch_IRQ_init(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_HITOLO(true);
in_config.pull = NRF_GPIO_PIN_NOPULL;
err_code = nrf_drv_gpiote_in_init(TOUCH_IRQ_PIN, &in_config, MPR121_check_pad_status); APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(TOUCH_IRQ_PIN, true);
SEGGER_RTT_printf(0, "Touch IRQ init complete.\n"); }
Then, UART0 along with UART IRQ handler is initialized (code is borrowed from Nordic UART example):
void UART_config( uint8_t rts_pin_number, uint8_t txd_pin_number, uint8_t cts_pin_number, uint8_t rxd_pin_number, uint32_t speed, bool hwfc) { nrf_gpio_cfg_output(txd_pin_number); nrf_gpio_cfg_input(rxd_pin_number, NRF_GPIO_PIN_PULLUP);
NRF_UART0->PSELTXD = txd_pin_number; NRF_UART0->PSELRXD = rxd_pin_number;
if (hwfc) { nrf_gpio_cfg_output(rts_pin_number); nrf_gpio_cfg_input(cts_pin_number, NRF_GPIO_PIN_NOPULL); NRF_UART0->PSELCTS = cts_pin_number; NRF_UART0->PSELRTS = rts_pin_number; NRF_UART0->CONFIG = (UART_CONFIG_HWFC_Enabled << UART_CONFIG_HWFC_Pos); }
NRF_UART0->BAUDRATE = (speed << UART_BAUDRATE_BAUDRATE_Pos); NRF_UART0->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos); NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos); NRF_UART0->TASKS_STARTTX = 1; NRF_UART0->TASKS_STARTRX = 1; NRF_UART0->EVENTS_RXDRDY = 0;
m_current_state = UART_READY;
NRF_UART0->INTENCLR = 0xffffffffUL; NRF_UART0->INTENSET = (UART_INTENSET_RXDRDY_Set << UART_INTENSET_RXDRDY_Pos) | (UART_INTENSET_TXDRDY_Set << UART_INTENSET_TXDRDY_Pos) | (UART_INTENSET_ERROR_Set << UART_INTENSET_ERROR_Pos);
NVIC_ClearPendingIRQ(UART0_IRQn); NVIC_SetPriority(UART0_IRQn, 1); NVIC_EnableIRQ(UART0_IRQn);
}
Touch IRQ handler works well (reacts on pin changes where MPR121 IRQ pin is connected, correct IRQ handler is fired up), until i enable GPS module, which starts to send NMEA strings to UART. Then, only handler that is fired up on incoming UART data, is MPR121_check_pad_status() which was set explicity to fire only on specific pin change, not UART events. UART0_IRQHandler(), which is also defined, is never fired at all.
Same UART code alone seems to work ok in a separate program dedicated to testing GPS interaction. Touch events code alone also works well, when UART code is not compiled in.