# Problem regarding serial port in rabbit RCM6700

**URL:** <https://forums.digi.com/t/problem-regarding-serial-port-in-rabbit-rcm6700/11617>\
**Category:** Embedded Devices\
**Tags:** rabbit6700\
**Created:** [June 17, 2013, 11:43pm UTC](https://forums.digi.com/t/problem-regarding-serial-port-in-rabbit-rcm6700/11617 "2013-06-17T23:43:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maniac84](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@maniac84](https://forums.digi.com/u/maniac84)\
**Post date:** [June 17, 2013, 11:43pm UTC](https://forums.digi.com/t/problem-regarding-serial-port-in-rabbit-rcm6700/11617/1 "2013-06-17T23:43:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![edha](https://avatars.discourse-cdn.com/v4/letter/e/ecccb3/32.png) [@edha](https://forums.digi.com/u/edha)\
**Post date:** [June 20, 2013, 5:29am UTC](https://forums.digi.com/t/problem-regarding-serial-port-in-rabbit-rcm6700/11617/2 "2013-06-20T05:29:17Z")

</div>

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

Try with this code:

```auto

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

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

// transmitte mode
serDflowcontrolOff();

// 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() &gt; 0) ;

// wait data sent to another device
waitfor(DelayMs(TX_TMOUT)); 

// receive mode
serDflowcontrolOn();

// read serial data in here...
n = serDread(packetIn, PACKET_LENGTH, RX_TMOUT);
if(n&gt;0){
    // process data input in here
}

```

regards,  
eda

---

<div class="post-metadata">

**Author:** ![maniac84](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@maniac84](https://forums.digi.com/u/maniac84)\
**Post date:** [June 24, 2013, 5:34am UTC](https://forums.digi.com/t/problem-regarding-serial-port-in-rabbit-rcm6700/11617/3 "2013-06-24T05:34:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![edha](https://avatars.discourse-cdn.com/v4/letter/e/ecccb3/32.png) [@edha](https://forums.digi.com/u/edha)\
**Post date:** [June 24, 2013, 10:35am UTC](https://forums.digi.com/t/problem-regarding-serial-port-in-rabbit-rcm6700/11617/4 "2013-06-24T10:35:39Z")

</div>

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.
