This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART write callback trigger point

Other Parts Discussed in Thread: SN65HVD72

MCU: TM4C1294NCPDT

TI-RTOS: v2.01.00.03

NDK: v2.23.01.01

CCS: v6.0.1.0040

-

Hi,

  I am facing an issue with the UART write callback function. My application is a serial port communication (half duplex) where data cannot be read & written simulteneously. Its an RS485 port where I need to write data & then read data that is coming back. At the other end of the serial RS485 bus is connected a MODBUS slave device which is supposed to reply to MODBUS queries sent to it. In hardware, we have used TI chip SN65HVD72 which is a bi-directional RS485 level converter. It has a DIRECTION pin (chip pin) which needs to be toggled low or high based on whether to enable the receiver or the transmitter respectively.

  The issue I am facing is that to determine the exact time when I need to toggle this pin (connected to a GPIO on the Tiva C MCU) from high to low i.e. to disable the transmitter & enable the receiver. This toggling of the GPIO needs to be done exactly after all the bytes in the transmission UART buffer is pushed out of the MCU. Ideally, I called the GPIO_write() function when the UART write callback function is called. But it looks like this function is called even before the first byte have got out of the device (MCU). As a result, the bytes are not coming out of the transreceiver chip as before the serial bytes arrive at its input side, the DIRECTION control pin disables the transmitter section. I think that this callback function will be called once the data (transmission data) is written to the UART buffer (even before the data is actually transmitted out of the MCU).

  How can I detect whether all the bytes have been transmitted out of the UART peripheral in the MCU? Is there a function to check whether there are any bytes pending in the UART transmission buffer that is waiting to be transmitted?

-

Thanks

-

Regards

Soumyajit