How to test the end of UART serial transmission

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

How to test the end of UART serial transmission

Jump to solution
2,181 Views
_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 Kudos
Reply
1 Solution
2,073 Views
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

 

View solution in original post

0 Kudos
Reply
3 Replies
2,146 Views
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 Kudos
Reply
2,136 Views
_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 Kudos
Reply
2,074 Views
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 Kudos
Reply