RS485 with 9 data bits

BergLoewe
Posts: 17
Joined: Wed Mar 18, 2020 10:34 am

RS485 with 9 data bits

Postby BergLoewe » Tue Feb 09, 2021 7:00 pm

Hello,

what can I do for work with the UART with 9 data bits? I have the example "uart_echo_rs485". Here is the statement

Code: Select all

	 uart_config_t uart_config = {
        .baud_rate = BAUD_RATE,
        .data_bits = UART_DATA_8_BITS,
        .parity = UART_PARITY_DISABLE,
        .stop_bits = UART_STOP_BITS_1,
        .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
        .rx_flow_ctrl_thresh = 122,
        .source_clk = UART_SCLK_APB,
    };
and I did change the .data_bits in

Code: Select all

	uart_config_t uart_config = { .baud_rate = BAUD_RATE,
			.data_bits = UART_DATA_BITS_MAX, 
			.parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1,
			.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, .rx_flow_ctrl_thresh = 122,
			.source_clk = UART_SCLK_APB, };
but this don't works.

Scott.Bonomi
Posts: 73
Joined: Mon Mar 09, 2020 7:36 pm

Re: RS485 with 9 data bits

Postby Scott.Bonomi » Wed Feb 10, 2021 1:35 am

I suggest you look up the definition of UART_DATA_BITS_MAX. Or set a log statement to print it. It appears to be a limit to a table not a functional number of bits.

BergLoewe
Posts: 17
Joined: Wed Mar 18, 2020 10:34 am

Re: RS485 with 9 data bits

Postby BergLoewe » Wed Feb 10, 2021 9:14 am

I did find this here
https://docs.espressif.com/projects/esp ... d_length_t

Here stays an option for 5, 6, 7, 8 and "max" data bits. I did hope, that "max" means 9 data bits.

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: RS485 with 9 data bits

Postby ESP_alisitsyn » Wed Feb 10, 2021 11:41 am

Hello @BergLoewe,

The UART does not support 9 data bits in the frame.
Each UART controller has the following features:
• Programmable baud rate
• 512 x 8-bit RAM shared by TX FIFOs and RX FIFOs of two UART controllers
• Full duplex asynchronous communication
• Automatic baud rate detection
• Data bits ranging from 5 to 8
• Stop bits whose length can be 1, 1.5, 2 bits
• Parity bits

However if you are going to use the Multidrop mode in RS485 communication the parity bit can be used to detect address. There is possibility to detect incorrect parity bit (UART_PARITY_ERR, UART_INTR_RS485_PARITY_ERR status bit) in the interrupt and handle it accordingly in the custom uart interrupt handler. Can it be useful for your project?

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 115 guests