UART hardware flow control - RTS set after 1 byte

DTynew
Posts: 2
Joined: Mon Aug 23, 2021 2:28 pm

UART hardware flow control - RTS set after 1 byte

Postby DTynew » Mon Aug 23, 2021 2:37 pm

I'm running a serial passthrough on my ESP32 and need to enable hardware flow control as I'm currently seeing some data loss and would like to rule this out. When I try to enable hardware flow control, the RTS goes high for every byte, making transfer speeds ridiculously slow.

I'm setting up flow control through the following:

Code: Select all

static const int RX_BUF_SIZE = 4096;

#define TXD_PIN (GPIO_NUM_15)
#define RXD_PIN (GPIO_NUM_13)
#define RTS_PIN (GPIO_NUM_14)
#define CTS_PIN (GPIO_NUM_12)

static void InitUART(void)
{
	ESP_LOGI(SPP_TAG, "Configuring UART");
	const uart_config_t uart_config = {
	        .baud_rate = 921600,
	        .data_bits = UART_DATA_8_BITS,
	        .parity = UART_PARITY_DISABLE,
	        .stop_bits = UART_STOP_BITS_1,
	        .flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
	        .source_clk = UART_SCLK_APB,
	    };

	// We won't use a buffer for sending data.
//	uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
	uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, RTS_PIN, CTS_PIN);
	ESP_ERROR_CHECK(uart_set_hw_flow_ctrl(UART_NUM_1, UART_HW_FLOWCTRL_CTS_RTS, UART_FIFO_LEN - 8));
	uart_driver_install(UART_NUM_1, RX_BUF_SIZE * 2, 0, 0, NULL, 0);
	uart_param_config(UART_NUM_1, &uart_config);
}
Does anyone have any suggestions on what might be causing this?

DTynew
Posts: 2
Joined: Mon Aug 23, 2021 2:28 pm

Re: UART hardware flow control - RTS set after 1 byte

Postby DTynew » Tue Aug 24, 2021 10:26 am

Solved it - I wasn't setting rx_flow_ctrl_thresh in my uart_config

Who is online

Users browsing this forum: Baidu [Spider], stvlaa and 74 guests