Home/Support/Support Forum/RCM6700 RS485
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

RCM6700 RS485

0 votes
I had welded RS485 chips(SP3072EE) on them.
connect first RCM57/67xx serial board RS485+ to second RS485+,RS485- to RS485-, GND to GND.
this is my cod, would you pls check?
1. master.c
#class auto

// include BLxS2xx series lbrary
#use "RS485.lib"

//#if _BOARD_TYPE_ == RCM4010 // BL4S210
// #define SER_NO_FLOWCONTROL
//#endif

// serial setup
#define FINBUFSIZE 255
#define FOUTBUFSIZE 255
#define ser485open serFopen
#define ser485wrFlush serFwrFlush
#define ser485rdFlush serFrdFlush
#define ser485putc serFputc
#define ser485getc serFgetc

nodebug
void msDelay(unsigned int delay)
{
unsigned long done_time;

done_time = MS_TIMER + delay;
while( (long) (MS_TIMER - done_time) < 0 );
}

///////////////////////////////////////////////////////////////////////////

void main()
{
int nIn1;
char cOut;

// Initialize the controller
brdInit();

ser485open(57600); // Set baud rate first

ser485wrFlush(); // Clear Rx and Tx data buffers
ser485rdFlush();

// Initializes serial mode and disables RS-485 transmitter
serMode(0);

// Sync up to the slave controller
printf ("Starting sync up with the other controller.\r");
cOut = 0x55;
do
{
ser485Tx(); // enable transmitter
ser485putc ( cOut ); // send lowercase byte
while ((nIn1 = ser485getc()) == -1); // wait for echo
ser485Rx(); // disable transmitter
msDelay(5);
if ((nIn1 = ser485getc ()) == -1) // check for reply
{
printf ("Waiting to sync up to the other controller.\r");
}
} while (nIn1 != cOut);

while (1)
{
for (cOut='a';cOut<='z';++cOut)
{
ser485Tx(); // enable transmitter
ser485putc ( cOut ); // send lowercase byte
while (ser485getc() == -1); // wait for echo
ser485Rx(); // disable transmitter

while ((nIn1 = ser485getc ()) == -1); // wait for reply
if (nIn1 == (toupper(cOut)))
{
printf ("\n\rUpper case %c is %c\n", cOut, nIn1 );
}
else
{
printf ("\n\rERROR: Sent %c and received %c\n", cOut, nIn1 );
}
}
}
}

2. slave.c
#class auto

// include BLxS2xx series lbrary
#use "RS485.lib"

//#if _BOARD_TYPE_ == RCM4010 // BL4S210
// #define SER_NO_FLOWCONTROL
//#endif

// serial buffer size
#define FINBUFSIZE 255
#define FOUTBUFSIZE 255
#define ser485open serFopen
#define ser485wrFlush serFwrFlush
#define ser485rdFlush serFrdFlush
#define ser485putc serFputc
#define ser485getc serFgetc

///////////////////////////////////////////////////////////////////////////
void main()
{
auto int i, nIn1;

// Initialize the controller
brdInit();

ser485open(57600); // Set baud rate first
ser485wrFlush(); // Clear Rx and Tx data buffers
ser485rdFlush();

// Initializes serial mode and disables RS-485 transmitter
serMode(0);

while (1)
{
while ((nIn1 = ser485getc()) == -1); // Wait for lowercase ascii byte
for (i = ((freq_divider*3) >> 1); --i; ); // Delay before transmit
ser485Tx(); // Enable transmitter
ser485putc ( toupper(nIn1) ); // Echo uppercase byte
while (ser485getc() == -1); // Wait for echo
ser485Rx(); // Disable transmitter
}
}

3. the lib is copy BLxSxx.lib,and named RS485.c, the follow is the part of modify.
#if BLXS200_SERIES
#fatal "This library is for BLxS2xx series SBC boards only."
#endif

#define SxER SFER
#define SxERShadow SFERShadow

#if _BOARD_TYPE_ == RCM4010
// available RS232 serial port B uses default port/pins
// available RS485 serial port C uses default port/pins
#define SET_GS(X) BitWrPortI(PFDR,&PFDRShadow,X,2)
#define BL_BUSY_REG PFDR
#define BL_BUSY_BIT 0
#else
#define SET_GS(X) BitWrPortI(PFDR,&PFDRShadow,X,4)
#define BL_BUSY_REG PFDR
#define BL_BUSY_BIT 4
#endif
related to an answer for: RCM6700 RS485
asked Jul 11, 2014 in Rabbit Software by superf4ur New to the Community (25 points)

Please log in or register to answer this question.

2 Answers

0 votes
What is the question?
answered Sep 15, 2014 by MargaretK Veteran of the Digi Community (545 points)
I can not get any output on the stdio,normally, I get the output"a b c...z" in the stdio.
0 votes
I can tell that the problem you are having is that you have modified the serial ports in some way so that you are no longer talking to the debugging console.

I tried the same modifications that you did to the code, and just including the RS485.lib (with modifications you suggest) disabled my ability to upload new firmware, which is another serial operation.

Did you ever get any further with this? I'm trying to get 485 to work on the RCM6000 series as well, and despite everything suggesting that this should be no problem I'm having a very hard time with it.
answered Oct 6, 2014 by dynamphorous New to the Community (4 points)
...