UARTE with HW flow control RTS stays high

Hello,

I am trying to test hardware flow control with UARTE1, with 115200 bps TX/RX is working fine with RTS/CTS always stay low(active). To prove flow control is working(that RTS can be used to stop other side sending) I tried to add delay in the UART ISR event handler to slow down the receiving, what I see now is that RTS stuck in high, from device log I see in SW we only received 2bytes, from logic analyzer I see there were 5 bytes transferred before RTS goes high. RTS never goes back low after this so RX is broken, any idea why this is happening? I also tried increased the baud rate to 460800 and saw a similar behavior.

My code is similar to this with double buffer for RX, and I didn't see any ERROR event triggered.

        case NRF_DRV_UART_EVT_ERROR:
            app_uart_event.evt_type                 = APP_UART_COMMUNICATION_ERROR;
            app_uart_event.data.error_communication = p_event->data.error.error_mask;
            (void)nrf_drv_uart_rx(&app_uart_inst, rx_buffer, 1);
            m_event_handler(&app_uart_event);
            break;

        case NRF_DRV_UART_EVT_TX_DONE:
            // Get next byte from FIFO.
            if (app_fifo_get(&m_tx_fifo, tx_buffer) == NRF_SUCCESS)
            {
                (void)nrf_drv_uart_tx(&app_uart_inst, tx_buffer, 1);
            }
            else
            {
                // Last byte from FIFO transmitted, notify the application.
                app_uart_event.evt_type = APP_UART_TX_EMPTY;
                m_event_handler(&app_uart_event);
            }
            break;

Thanks,

-Rui

  

  • Hi,

    I tried to add delay in the UART ISR event handler to slow down the receiving, what I see now is that RTS stuck in high, from device log I see in SW we only received 2bytes, from logic analyzer I see there were 5 bytes transferred before RTS goes high. RTS never goes back low after this so RX is broken, any idea why this is happening?

    How many bytes are setup to receive?

    How long is the delay that you've added? The _ENDRX event is cleared before the callback handler is called in the driver itself, so I would assume that you get the callback twice.

     

    Kind regards,

    Håkon

  • Hi Hakon,

    The setup is to receive ~100 bytes, I tried manually sending from the other side but it's blocked b/c CTS(Nrf RTS) is high.

    I added 20us in the UART ISR to slow down the RX path and this also happens when I tune up the UART bps to 460800. It seems like I am only getting the ISR event for the first two bytes, is the ISR triggered per byte received?

    Thanks,

    -Rui 

  • Hi,

     

    Ray Ma said:
    The setup is to receive ~100 bytes, I tried manually sending from the other side but it's blocked b/c CTS(Nrf RTS) is high.

    How many bytes do you set to receive?

    You mention that your code is similar to the snippet, but that snippet is effectively from app_uart_fifo.c.

    app_uart_fifo will setup RX on one byte, and if you know how many bytes you will receive each time, I would strongly recommend that you use the nrfx_uarte directly instead, to get better control over the transport (ie. set the RXD DMA length).

     

    If your application sets up one byte RX via nrf_drv_uart_rx(...), then it is approx. 22 us per byte in 460k8 baud, which will cause a timing error.

     

    Kind regards,

    Håkon

Related