GPIOTE resource conflict

Hello, I encountered a problem while using the nrf5 SDK. In my software, I used a UART for debugging data output, a libuarte library for command output, and an app_button library to use my buttons. Since libuarte needs to dynamically switch the baud rate for command output, I found that when I reinitialized libuarte and then changed the baud rate and reinitialized it, an error occurred: <error> app: ASSERTION FAILED at F:\kiki\test_app\aqp-arp-test\modules\nrfx\drivers\src\nrfx_gpiote.c:473. However, when I commented out buttons_init and switched, this error did not occur and the baud rate could be switched normally. What could be the reason for this?
Thanks

int main(void)
{
    bool erase_bonds;
    uint32_t err_code;
    static uint32_t loop_counter = 0;
    static uint32_t last_auto_send_time = 0;


    ret_code_t ret = nrf_drv_clock_init();
    APP_ERROR_CHECK(ret);

    nrf_drv_clock_lfclk_request(NULL);

    log_init();
    NRF_LOG_INFO("RTT log initiallized\r\n");
    timers_init();
    uart2_log_init();
    test_uart_init();
    buttons_init();

    test_uart_change(NRF_UARTE_BAUDRATE_115200);

    at_system_init();
    uart2_log_print("Buttons initialized\r\n");

    power_management_init();

    uart2_log_print("Power management initialized\r\n");
    db_discovery_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    nus_c_init();
 get_and_set_mac_address();
void test_uart_init(void)
{
    uint32_t err_code;

    nrf_libuarte_async_config_t nrf_libuarte_async_config = {
        .tx_pin = TX_PIN_NUMBER,
        .rx_pin = RX_PIN_NUMBER,
        .baudrate = NRF_UARTE_BAUDRATE_921600,
        .parity = NRF_UARTE_PARITY_EXCLUDED,
        .hwfc = NRF_UARTE_HWFC_DISABLED,
        .timeout_us = 100,
        .int_prio = APP_IRQ_PRIORITY_LOW};

    err_code = nrf_libuarte_async_init(&libuarte, &nrf_libuarte_async_config, uart_event_handler, (void *)&libuarte);

    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR("UART init failed , %d", err_code);
    }
    APP_ERROR_CHECK(err_code);

    nrf_libuarte_async_enable(&libuarte);
}

void test_uart_change(nrf_uarte_baudrate_t BAUD)
{
    uint32_t err_code;

    NRF_LOG_INFO("Starting UART baudrate change to %d", BAUD);

    nrf_libuarte_async_uninit(&libuarte);


    nrf_delay_ms(100);


    nrf_libuarte_async_config_t config = {
        .tx_pin = TX_PIN_NUMBER,
        .rx_pin = RX_PIN_NUMBER,
        .baudrate = BAUD,
        .parity = NRF_UARTE_PARITY_EXCLUDED,
        .hwfc = NRF_UARTE_HWFC_DISABLED,
        .timeout_us = 100,
        .int_prio = APP_IRQ_PRIORITY_LOW};

    err_code = nrf_libuarte_async_init(&libuarte, &config, uart_event_handler, (void *)&libuarte);
    APP_ERROR_CHECK(err_code);
    nrf_libuarte_async_enable(&libuarte);

}

  • Hi!

    ASSERTION FAILED at F:\kiki\test_app\aqp-arp-test\modules\nrfx\drivers\src\nrfx_gpiote.c:473

    So this assert happen in nrfx_gpiote_set_task_get(), and looks like this:

    NRFX_ASSERT(pin_in_use_by_te(pin));
    So could be that you did not uninitialize it properly beforehand.
    Maybe try calling nrfx_gpiote_in_uninit(#pin_number)
Related