User`s manual
RabbitFLEX User’s Manual www.rabbit.com 127
ser485Tx
void ser485Tx(void);
DESCRIPTION
Enables the RS-485 transmitter. The brdInit() function must be executed before running this
function. This function is non-reentrant.
After the byte or block of data has been transmitted, the RS-485 transmitter must be idle and its
transmit buffer empty before an application can disable the transmitter and thus receive data from
the RS-485 interface. There are two methods for identifying when to disable the transmitter.
1. Poll the receive data buffer for the transmitted data that is echoed back to it. This is the easier
method. The following code snippet illustrates disabling the transmitter after one byte has been
transmitted using serial port C. You can also send a block of data before disabling the transmit-
ter.
ser485Tx(); // enable transmitter
serCputc ( 0x55 ); // send byte
while (serCgetc() == -1); // wait for echo
ser485Rx(); // disable transmitter
2. Read SxSR, the status register of the serial port you are using. Bits 2 and 3 report on the RS-485
transmitter and its buffer. The following code snippet illustrates how to check these bits if you
are using serial port C.
ser485Tx();
serCputc(0x55);
// Wait for Tx Data buffer to become empty
while(serCwrFree() != COUTBUFSIZE);
// Wait for Tx buffer and shift register on uP to become empty
while(RdPortI(SCSR)&0x08 || RdPortI(SCSR)&0x04);
ser485Rx();
RETURN VALUE
None
SEE ALSO
brdInit, ser485Rx