EasyManua.ls Logo

Rabbit 2000 - RS-485 Serial Communication Sample Program

Rabbit 2000
54 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Getting Started Manual 25
3.1.3 RS-485 Serial Communication Sample Program
The following sample program illustrates the use of the RS-485 serial drivers. The sample
program shows a byte being transmitted, and then the RS-485 transceiver waits for a reply.
NOTE: If your version of Dynamic C is earlier than 6.55, see Technical Note 117, Jack-
rabbit (BL1800 Series) RS-485 Bulletin, for information on restrictions on using both
DA1 and RS-485 at the same time.
#define DINBUFSIZE 15
#define DOUTBUFSIZE 15
void main( void ){
int nEcho,nReply;
char cChar;
Jr485Init ();// Init RS485 Control (PD5)
serDopen ( 9600 );// Open Serial Port D
for (;;) {// Forever
for (cChar='a';cChar<='z';++cChar){
// Send Alphabet
Jr485Tx ();// Enable RS485 Transmitter
serDputc ( cChar );// Send Byte
while ((nEcho = serDgetc ()) == -1);
// Wait for Echo
Jr485Rx ();// Disable RS485 Transmitter
while ((nReply = serDgetc ()) == -1);
// Wait for Reply
printf ( "%02x -> %02x\n",nEcho,nReply );
}
}
}
Downloaded from Elcodis.com electronic components distributor

Other manuals for Rabbit 2000