RCM6700 RS485

Hello

anyone have RS485 code for RCM6700? I had modified the BLXS2XX’s RS485 code, then run, it always"Starting sync up with the other controller" in the stdio, where the issues?

Thanks!

Modified how?

The RCM6700 does not have an RS485 chip on it. To add an external RS485 chip you will need to write the driver for it.

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&lt;='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 ("

\rUpper case %c is %c
“, cOut, nIn1 );
}
else
{
printf (”
\rERROR: Sent %c and received %c
", cOut, nIn1 );
}
}
}
}

  1. 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) &gt;&gt; 1); --i; ); // Delay before transmit
	ser485Tx();										//	Enable transmitter
	ser485putc ( toupper(nIn1) );				//	Echo uppercase byte
	while (ser485getc() == -1);				//	Wait for echo
	ser485Rx();										//	Disable transmitter
}

}

  1. 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