Page 1 of 1

uart_param_config() returns an error

Posted: Wed Mar 18, 2020 5:11 pm
by egoncalves
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

Re: uart_param_config() returns an error

Posted: Thu Mar 19, 2020 8:26 am
by ESP_Sprite
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.

Re: uart_param_config() returns an error

Posted: Thu Mar 19, 2020 3:48 pm
by egoncalves
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.

Re: uart_param_config() returns an error

Posted: Sat Oct 16, 2021 1:05 pm
by moefear85
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.