Get additional one byte of value 0 for i.mx6ull UART8 as RS485

cancel
Showing results for 
Search instead for 
Did you mean: 

Get additional one byte of value 0 for i.mx6ull UART8 as RS485

136 Views
lonsn
Contributor I

In a custom i.mx6ull board, we use UART8 as RS485 interface. Data sent is OK, however when we open this port the rs485 application will read one byte data with 0(no data is sent from other rs485 endpoint in this bus). After that we will get normal correct rs485 data. For other UART/RS485 port in the same board, it works fine without this problem.

DTS file as below:

pinctrl_uart8dce: uart8dcegrp {
fsl,pins = <
MX6UL_PAD_LCD_DATA20__UART8_DCE_TX 0x1b0b1
MX6UL_PAD_LCD_DATA21__UART8_DCE_RX 0x1b0b1
MX6UL_PAD_LCD_DATA04__UART8_DCE_CTS 0x1b0b1 /* RS485 RE/DE */
MX6UL_PAD_LCD_DATA05__UART8_DCE_RTS 0x1b0b1
>;
};

What's the root cause?

Labels (1)
0 Kudos
3 Replies

65 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi lonsn,

    Please test it like below!

1. power off your board

2. remove other devices on UART8/RS485 bus.

3. power on your board.

4. run your application, and check if the issue still exists.

Have a nice day!

B.R,

Weidong

0 Kudos

65 Views
lonsn
Contributor I

Yes, same issue. We use same test program in other RS485 port and it works good. Only UART8 has this issue.

0 Kudos

65 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi lonsn,

The following ways are used to flush buffer(IN/OUT), you can try one of them after open uart device.

(1) Using tcflush function

fd = open("devpath", O_RDWR|O_NOCTTY);
usleep(200000);
tcflush(fd, TCIFLUSH);    //Clear receiving buffer
tcflush(fd, TCOFLUSH);    //Clear transmiting buffer
tcflush(fd, TCIOFLUSH);   //Clear receiving & transmitting buffer
tcsetattr(fd, TCSANOW, &strctNewTermios);

(2)Using ioctl function

fd = open("devpath", O_RDWR|O_NOCTTY);
usleep(200000);
ioctl(fd, TCFLSH, 0);    //Clear receiving buffer
ioctl(fd, TCFLSH, 1);    //Clear transmiting buffer
ioctl(fd, TCFLSH, 2);    //Clear receiving & transmitting buffer
tcsetattr(fd, TCSANOW, &strctNewTermios);

Hope above code is helpful to you.

Have a nice day!

B.R,

Weidong

0 Kudos