How to test the end of UART serial transmission

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

How to test the end of UART serial transmission

跳至解决方案
2,184 次查看
_Ferrari_
Contributor V

Dear all

I'm developing a project based on LPC5526 CPU. I have to implement RS-485 communication so I have to set an extarnal RS485 driver in RX or TX mode. To do that I'm using a GPIO output port bit.

But, before switching from TX to RX, I must be sure that the trasnsmitted data is phisically completely shifted out from the serial Tx pin of the CPU.

So I have to check if

Internal Tx FIFO is empty

and


data byte is phisically completely shifted out from the serial Px PIN of the CPU

...
if( TxFitoIsEmpty() } {
   if( DataByteIsCompletelyShiftedOut() ) {
       setDeviceToTxMode();
   }
}
.....

What are the right status USART flags that I have to check ?

Thank you very much for your help and cooperation

regards

0 项奖励
回复
1 解答
2,076 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I am sorry, I mean the UM11126.pdf rather than UM11026.pdf, the UM11126.pdf can be downloaded from the link:

https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mc...

 

You can refer to the section 34.7.7 RS-485 support in UM11126.pdf

Regarding your question to use GPIO to control the direction of RS485 chip, it seems okay that you disable Transmitter FIFO, check both the FIFOSTAT[TXEMPTY] and the STAT[TXIDLE] before you set the GPIO to enable transmitting and write the transmitter data.

Hope it is helpful

BR

XiangJun Rong

 

在原帖中查看解决方案

0 项奖励
回复
3 回复数
2,149 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

As the following section in UM11026.pdf, you can connect the RTS signal to the the direction pin of RS-485 IC, which can control the direction automatically when you send character.

 
 
 

xiangjun_rong_0-1687682621399.png

Maybe there is problem if you use GPIO pin to control the direction, because there is only TXEMPTY bit in FIFO status register, which means that the FIFO is empty, the data has been copied to the shift register, but it does not reflect that the sift register has completed the data shifting.

Hope it can help you

BR

XiangJun Rong

 

 

0 项奖励
回复
2,139 次查看
_Ferrari_
Contributor V

Ok,

thank you very much for your reply.

Unfortunately i can't find the UM11026.pdf on the web. Could you pass me alink of such document ?

If I use GPIO instead of RTS (for hardware restriction) can I check kUSART_TxIdleFlag to know if the data is completely shifted out ?


thank you very much for your help and cooperation

regards

0 项奖励
回复
2,077 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I am sorry, I mean the UM11126.pdf rather than UM11026.pdf, the UM11126.pdf can be downloaded from the link:

https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mc...

 

You can refer to the section 34.7.7 RS-485 support in UM11126.pdf

Regarding your question to use GPIO to control the direction of RS485 chip, it seems okay that you disable Transmitter FIFO, check both the FIFOSTAT[TXEMPTY] and the STAT[TXIDLE] before you set the GPIO to enable transmitting and write the transmitter data.

Hope it is helpful

BR

XiangJun Rong

 

0 项奖励
回复