2 stop bits

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2 stop bits

Jump to solution
2,204 Views
adrianc
Contributor II

Hi,

We have an application that requires serial communications with a peripheral, and this peripheral requires us to send out the data stream with 2 stop bits, however it sends in a data stream with only 1 stop bit.

The data sheet specifically states that when the "2 stop bit" configuration bit is set in the uart control register, the receiver will NOT look for 2 stop bits as a condition on incoming data. However, all our investigations show this is not true, and we are getting bad data and framing errors on input.

Is this a h/w issue (or a typo in the data sheet)?

Can it be corrected with firmware?

We are running linux on this platform

Thanks, Adrian

Labels (1)
Tags (2)
0 Kudos
1 Solution
1,860 Views
adrianc
Contributor II

The UART can be configured as a whole, i.e. settings for the TX and RX sides are common, or the TX and RX sections can be configured individually. Thus setting different stop bit, parity, data lengths for each section. By default the Linux drivers set the UART as a whole, the following sequence inserted into the serial drivers allow the application to behave as we want, 2 stop bits outgoing, 1 stop bit incoming:

1st line puts the same configuration in the control registers for TX and RX. The global line control register becomes the RX line control register, the 2 line control registers is used for the TX section.

2nd line tells the UART to apply the 2 control registers for settings, 1 for TX 1 for RX

3rd line changes the settings in the TX section of the UART.

1. Copy the HW_UARTAPP_LINECTRL register into the HW_UARTAPP_LINECTRL2 regfister
2. Set the USE_LCR2 bit in the HW_UARTAPP_CTRL2 register.
3. Set the STP2 bit in the HW_UARTAPP_LINECTRL2 register.

View solution in original post

0 Kudos
4 Replies
1,861 Views
adrianc
Contributor II

The UART can be configured as a whole, i.e. settings for the TX and RX sides are common, or the TX and RX sections can be configured individually. Thus setting different stop bit, parity, data lengths for each section. By default the Linux drivers set the UART as a whole, the following sequence inserted into the serial drivers allow the application to behave as we want, 2 stop bits outgoing, 1 stop bit incoming:

1st line puts the same configuration in the control registers for TX and RX. The global line control register becomes the RX line control register, the 2 line control registers is used for the TX section.

2nd line tells the UART to apply the 2 control registers for settings, 1 for TX 1 for RX

3rd line changes the settings in the TX section of the UART.

1. Copy the HW_UARTAPP_LINECTRL register into the HW_UARTAPP_LINECTRL2 regfister
2. Set the USE_LCR2 bit in the HW_UARTAPP_CTRL2 register.
3. Set the STP2 bit in the HW_UARTAPP_LINECTRL2 register.

0 Kudos
1,860 Views
raymondwang
Senior Contributor I

Be sure you set termios c_cflag with CSTOPB.

0 Kudos
1,860 Views
adrianc
Contributor II

It is precisely when that bit is set that we have the problems:

outgoing data has the 2 stop bits

incoming data does not, however the uart expects it to have 2 stop bits, whereas our expectation is that it should not (cf data sheet)

Thanks, Adrian

0 Kudos
1,860 Views
raymondwang
Senior Contributor I

Please mark this issue as answered.

0 Kudos