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

[Bug Report] app_uart_close does not free gpiote channel when using APP_UART_FLOW_CONTROL_LOW_POWER

SDK_9.0.0

I was trying to implement 2 different UART connection parameters so I decide to use re-initialization. My initial parameters included APP_UART_FLOW_CONTROL_LOW_POWER, when I wanted to re-initialize UART with new parameters I did something like this:

app_uart_close(app_uart_uid);
err = app_uart_init(p_comm_params, &uart_buffers, uart_event_handler_p,uart_irq_prio, &app_uart_uid);

To my surprise app_uart_init returned NRF_ERROR_NO_MEM. What would suggest that I have no free gpiote channel. I thought "Hey, I have already init once UART then I close it so what is wrong ?" It occured that inside app_uart_close () :

uint32_t app_uart_close(uint16_t app_uart_uid)
{
    if (app_uart_uid < UART_INSTANCE_GPIOTE_BASE)
    {
        on_uart_event(ON_UART_CLOSE);
        return NRF_SUCCESS;
    }

    on_uart_event(ON_UART_CLOSE);

    nrf_drv_gpiote_in_uninit(NRF_UART0->PSELCTS);
    return NRF_SUCCESS;
}

nrf_drv_gpiote_in_uninit was not even called by the program. (so there was no chance to clear gpiote channel). When I have removed if block, nrf_drv_gpiote_in_uninit was called with NRF_UART0->PSELCTS = 4294967295 (0xFFFFFFFF - UART_PIN_DISCONNECTED) and my program failed again. I had to call nrf_drv_gpiote_in_uninit with NRF_UART0->PSELCTS = 4 (4 number of pin of my CTS) to be able to multiplex 2 different UART connection parameters and pins numbers with APP_UART_FLOW_CONTROL_LOW_POWER option. I think there might be some bug in app_uart_init for this flow control but I had no time to dig deeper into this issue , with APP_UART_FLOW_CONTROL_ENABLED everything works fine.

Related