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
Solved! Go to Solution.
Hi,
I am sorry, I mean the UM11126.pdf rather than UM11026.pdf, the UM11126.pdf can be downloaded from the link:
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
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.
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
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
Hi,
I am sorry, I mean the UM11126.pdf rather than UM11026.pdf, the UM11126.pdf can be downloaded from the link:
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