UART 3 Stop bits is undefined

kurto1396
Posts: 4
Joined: Sun Mar 19, 2023 6:10 pm

UART 3 Stop bits is undefined

Postby kurto1396 » Sun Mar 19, 2023 6:27 pm

In https://www.espressif.com/sites/default ... ual_en.pdf

UART_STOP_BIT_NUM This register is used to set the length of the stop bit; 1: 1 bit, 2: 1.5 bits. (R/W)

Defines stop bits for the URAT to be 1,1.5, and 2

this also aligns with the arduino drivers

typedef enum {
UART_STOP_BITS_1 = 0x1, /*!< stop bit: 1bit*/
UART_STOP_BITS_1_5 = 0x2, /*!< stop bit: 1.5bits*/
UART_STOP_BITS_2 = 0x3, /*!< stop bit: 2bits*/
UART_STOP_BITS_MAX = 0x4,
} uart_stop_bits_t;

However, 3 stop bits should be supported

13.3.5 UART Data Frame
Figure 13-3 shows the basic data frame structure. A data frame starts with a START condition and ends with a
STOP condition. The START condition requires 1 bit and the STOP condition can be realized using 1/1.5/2/3-bit
widths (as set by UART_STOP_BIT_NUM, UART_DL1_EN, and UAR_DL0_EN). The START is low level, while the
STOP is high level.

What are the register settings for 3 uart stop bits?

Thank you!

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

Re: UART 3 Stop bits is undefined

Postby ESP_Sprite » Mon Mar 20, 2023 12:58 am

Looks like, as the text implies, you can use UART_DL1_EN and UAR_DL0_EN to add extra bits to the stop bit amount defined there. It's not super-well documented as devices rarely need 2 stop bits, let alone 3.
EDIT: This is wrong, look at the reply of my colleague below instead.

ESP_wangning
Posts: 17
Joined: Wed Jan 06, 2021 8:21 am

Re: UART 3 Stop bits is undefined

Postby ESP_wangning » Mon Mar 20, 2023 3:19 am

Hi there, I'm sorry for the trouble caused by the unclear register descriptions.

UART_STOP_BIT_NUM, which is used to set the length of stop bits, has 4 valid values. 0: 1 bits; 1: 2 bits; 2: 1.5 bits; 3: 3 bits.
UART_DL1_EN and UART_DL0_EN are used to set the turnaround delay as required by the RS485 protocol. It has nothing to do with the length of stop bits. This function is documented in Section 26.4.2 Turnaround Delay https://www.espressif.com/sites/default ... n#uart.pdf

I will update the descriptions in TRM in the next release.

kurto1396
Posts: 4
Joined: Sun Mar 19, 2023 6:10 pm

Re: UART 3 Stop bits is undefined

Postby kurto1396 » Wed Mar 22, 2023 4:20 am

Thank you, but this doesn't seem to align with the code.

From your post
UART_STOP_BIT_NUM, which is used to set the length of stop bits, has 4 valid values. 0: 1 bits; 1: 2 bits; 2: 1.5 bits; 3: 3 bits.
From the code I see
https://github.com/espressif/arduino-es ... rt_types.h (line 56)

Code: Select all

typedef enum {
UART_STOP_BITS_1 = 0x1, /*!< stop bit: 1bit*/
UART_STOP_BITS_1_5 = 0x2, /*!< stop bit: 1.5bits*/
UART_STOP_BITS_2 = 0x3, /*!< stop bit: 2bits*/
UART_STOP_BITS_MAX = 0x4,
} uart_stop_bits_t;
Which translates to 0: undefined, 1: 1 bits; 2: 1.5 bits; 3: 2 bit. There is agreement that 2 means 1.5 stop bits, but the values for 0,1, and 3 are not in agreement.

Additionally, the current documentation on page 520
https://www.espressif.com/sites/default ... ual_en.pdf
says:
UART_STOP_BIT_NUM This register is used to set the length of stop bit. 1: 1 bit. 2: 1.5 bits. 3: 2 bits. (R/W)
This also agrees with the code.

Is it possible 0 is used to represent 3 stop bits?

I am new the forum. Where should this be cross posted to hopefully get

Code: Select all

uart_stop_bit_t
data structure updated to include 3 stop bits and

Code: Select all

esp_err_t uart_set_stop_bits(uart_port_t uart_num, uart_stop_bits_t stop_bits)
updated to handle it.

Thank you!

kurto1396
Posts: 4
Joined: Sun Mar 19, 2023 6:10 pm

Re: UART 3 Stop bits is undefined

Postby kurto1396 » Wed Mar 29, 2023 6:45 pm

Hi @ESP_wangning, do you have any thoughts or suggestions on the best next step to figure this out?

Thank you!

ESP_wangning
Posts: 17
Joined: Wed Jan 06, 2021 8:21 am

Re: UART 3 Stop bits is undefined

Postby ESP_wangning » Thu Apr 06, 2023 3:50 am

Sorry that I just noticed your reply!
It seems that there is some inconsistency between hardware and software. I'm checking and will keep you updated.

ESP_wangning
Posts: 17
Joined: Wed Jan 06, 2021 8:21 am

Re: UART 3 Stop bits is undefined

Postby ESP_wangning » Thu Apr 06, 2023 10:02 am

Sorry that my previous explanation is wrong.

The length of stop bits can be 1, 1.5 or 2, configured by UART_STOP_BIT_NUM.
0: Invalid. No effect
1: 1 bits
2: 1.5 bits
3: 2 bits

In RS485 mode, you may add a turnaround delay of a bit before the start bit or after the stop bit, configured by UART_DL0_EN or UART_DL1_EN respectively. If you add one turnaround delay, this is actually what we mean by "3 stop bits".
You can add two turnaround delays before the start bit and after the stop bit at the same time, or in other words the "stop bits" can be 4 bits long at most.

We will make the descriptions clearer in the next TRM release.

Craige Hales
Posts: 94
Joined: Tue Sep 07, 2021 12:07 pm

Re: UART 3 Stop bits is undefined

Postby Craige Hales » Thu Apr 06, 2023 6:05 pm

Explanation of why 2 stop bits were needed for a mechanical TTY https://retrocomputing.stackexchange.com/a/631
Extra stop bit(s) might be needed to slow down a datastream, but it would be pretty unusual for hardware less than about 30 years old.
Craige

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

Re: UART 3 Stop bits is undefined

Postby ESP_Sprite » Fri Apr 07, 2023 12:40 am

If you need this, possibly you can use the RMT peripheral to implement a semi-software UART?

kurto1396
Posts: 4
Joined: Sun Mar 19, 2023 6:10 pm

Re: UART 3 Stop bits is undefined

Postby kurto1396 » Wed Apr 19, 2023 6:14 am

Thank you! Sorry I missed your reply. I will look into the RMT. I am trying to use this to connect into a DMX data stream of a lighting console. The MTBF I think can be handled as an extra stop bit.

Image
https://www.theatreartlife.com/staying- ... mystified/

Who is online

Users browsing this forum: No registered users and 42 guests