RS485 the best way to control EN signal?

Hello,

As you know we have to control EN signal for transmiting data through RS485 line. There is simple way to control this signal. We enable TX line on RS485 bus, when we send data and wait while all data will be transmitted and finally we disabe TX line. The code would be like this:

#define TX485EN(i) BitWrPortI( PDDR, &PDDRShadow, i,6 )
TX485EN(1);
serEwrite(“DATA”,4);
while(serEwrFree()!=EOUTBUFSIZE);
while (BitRdPortI(STSER_REG,3) || BitRdPortI(STSER_REG,2));
TX485EN(0);

But the problem is waiting all time while data will be transmitted!!!. Imagine if you send 300bytes in 9600kbit/s. You have to wait about 313ms !!! at this time you can’t do anythink just wait.

Question: Did anybody try to modify DC library that a serial interrupt self disable TX signal when all data will be transmitted from a serial loop buffer?
I would like that the serial interrupt controls EN line. :confused:
I’m using DC9.62 and RCM3100.

Taris

Best regards
Thanks for your ideas

I use a 74HC221 to trigger a pulse on the start bit of each character in the data output stream. The approach demands a known baudrate from which you can determine the needed delay (9600,8,N,1 would need just above 1ms delay per character)

Henrik

Henrik,

Could you describe more detail how should I connect the trigger pin for the adjustable delay?

Best regards
Taris

I have used the attched scheme several times when interfacing an RS232 to and RS485 line.

Henrik

Could someone please repost these images?
Tx
Cow

Here is the file RS232toRS485sm.JPG. I hope it will bee useful for somebody