Forum Discussion
Altera_Forum
Honored Contributor
13 years agoThere is a number of solutions for this. Which is better mostly depends on your application and the level of performance you need to achieve.
You also must consider the behavior of other RS485 parties: after you have transmitted your data you must release the rs485 lines (by deasserting the transmit enable pin) before any other rs485 device possibily initiates a new transmission. If they are supposed to answer to your tx data, you may need to deassert tx enable just after the last transmitted word: so, if baud rate is high, a hardware solution could be the better choice. On the other hand, for medium-low baudrates or higher tx-rx delays, you could rely on a software solution which is generally easier to implement. For myself, I always stayed on a software implementation: even with baudrates up to 320000bps, I could achiev almost zero end-tx to txen-deassertion delays using the rx-complete interrupt. Please note that in some uart implementations the tx-complete interrupt signals the START of trasmission of last word, not the transmission end: if you use the irq to deassert txen, you will definitely lose the last data word. In such cases you could adopt a simple trick: add a fake invalid word at the end of the tx stream and use it only to trigger the isr just after the last true data has been transmitted.