Problem regarding serial port in rabbit RCM6700

Hi guys, I’m using the rabbit RCM6700 to do some coding using C programming and I’m using the Dynamic C 10.66 compiler.
I want to do simple RS485 transmit and receive using serial port D, so I added the library file RS232.lib into the project files. I connect the RCM6700 to one rs485 ic (MAX3072). I use a control pin (PE1) from RCM6700 to the rs485 ic to control the rs485 ic whether it do receiving or transmitting. I will use the serDrdUsed() function to see whether I have receive data or not.
The problem I face is, everytime I set control pin PE1 to high (transmitting mode), the serDrdUsed() will have some value. Aren’t serDrdUsed() will only have value if I set PE1 to low (receiving mode) and when I receive some data?

RS485 is half duplex communication. Transmission and reception of data can’t be done simultaneously.

Try with this code:

#define TX_TMOUT 2UL
#define RX_TMOUT 20UL
#define PACKET_LENGTH 32

char packetOut[PACKET_LENGTH], packetIn[PACKET_LENGTH], n;

// transmitte mode

// store data to packetOut
sprintf(packetOut, "%s", "this is the data to be sent");

// send data
serDwrite(packetOut, strlen(packetOut)); 
// wait buffer output empty
while (serDwrUsed() > 0) ;

// wait data sent to another device

// receive mode

// read serial data in here...
n = serDread(packetIn, PACKET_LENGTH, RX_TMOUT);
    // process data input in here


I know that RS485 is half duplex communication.
I found out that when I transmit out data using serDputc() command, the serDrdUsed() will be >0. Aren’t that serDrdUsed() will be >0 when only we receive data?

Is pin /RE of MAX3072 connected to GND? If yes, that hardware configuration for echo mode. Cut wiring from /RE to GND then connect pin /RE to pin DE of MAX3072.
RS485 will transmite mode when you set high /RE and DE, and vice versa.