lpcware

Synchronizing GPIO with UART state.

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by nakedible on Sat Nov 16 14:34:55 MST 2013
Hello,

I have a half-duplex RS-485 transceiver that has a separate "tx enable" line that I need to control. I need to turn "tx enable" on before the first start bit of a message, and turn it off after the last stop bit of a message. My solution to this was to turn the GPIO on when TXRDY was set in UART state flags, and turn it off after disabling the transmitter when TXDISINT flag was sent.

However, it seems that TXRDY is set *after* the start bit has already been sent, so this is too late. I tried setting the GPIO when enabling the transmit, but that meant that the transmit was enabled around 200 microseconds too early, two bits at 9600. Is there any way to get an interrupt or poll something that would let me know exactly when the start bit is being sent?

The same kind of problem exists for TXDISINT. This flag is set after the last data bit has been sent, but the stop bit is yet to be sent. If I turn the transmitter off at this point, the stop bit will not be transmitted on the wire. Is there any way to get an interrupt or poll something that would let me know exactly when the stop bit has been sent?

I can work around both of these issues somewhat with timers, but that would seem exceedingly ugly. At the moment, I am simply considering switching processors :-(

Outcomes