2 stop bits

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

2 stop bits

跳至解决方案
3,503 次查看
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

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
3,159 次查看
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 项奖励
回复
4 回复数
3,160 次查看
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 项奖励
回复
3,159 次查看
raymondwang
Senior Contributor I

Be sure you set termios c_cflag with CSTOPB.

0 项奖励
回复
3,159 次查看
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 项奖励
回复
3,159 次查看
raymondwang
Senior Contributor I

Please mark this issue as answered.

0 项奖励
回复