uart_param_config() returns an error

egoncalves
Posts: 22
Joined: Thu Jan 23, 2020 9:31 am

uart_param_config() returns an error

Postby egoncalves » Wed Mar 18, 2020 5:11 pm

Hi

I'm calling uart_param_config() like this:

uart_config_t uartConfig;
uartConfig.baud_rate = baudrate;
uartConfig.data_bits = UART_DATA_8_BITS;
uartConfig.parity = UART_PARITY_DISABLE;
uartConfig.stop_bits = UART_STOP_BITS_1;
uartConfig.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;
uartConfig.rx_flow_ctrl_thresh = 1000/*bufferSize*/ *9/10;
uartConfig.use_ref_tick = false;

err = uart_param_config (UART_NUM_1, &uartConfig);

and I get this error:

E (3559) uart: uart_set_hw_flow_ctrl(276): rx flow thresh error

If I use a smaller buffer size like 100 it works ok.
Any ideas about this?

thanks

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: uart_param_config() returns an error

Postby ESP_Sprite » Thu Mar 19, 2020 8:26 am

First of all, I don't think this field will have any effect with uartConfig.flow_ctrl set to UART_HW_FLOWCTRL_DISABLE. Secondly, this is a hardware feature and the threshold is measured against how full the UARTs hardware FIFO is; as such it cannot be set to a larger value than the amount of bytes available in that FIFO.

egoncalves
Posts: 22
Joined: Thu Jan 23, 2020 9:31 am

Re: uart_param_config() returns an error

Postby egoncalves » Thu Mar 19, 2020 3:48 pm

Thanks and understood.
It seems that the routine checks the field rx_flow_ctrl_thresh even when flow_ctrl is set to UART_HW_FLOWCTRL_DISABLE!
And therefore generates the error.

moefear85
Posts: 44
Joined: Sun Sep 05, 2021 4:55 pm

Re: uart_param_config() returns an error

Postby moefear85 » Sat Oct 16, 2021 1:05 pm

yeah when filling out the structure like that, you need to explicitly set the thresh field to 0, otherwise it gets filled with stack garbage hence makes esp-idf throw an error.

Who is online

Users browsing this forum: Bing [Bot], pkf1111 and 164 guests