NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages
ex_RS485Send.nxc

This is an example of how to use the RS485Control, RS485Disable, RS485Initialize, RS485Enable, UseRS485, RS485Uart, RS485Status, RS485Write, RS485SendingData, SendRS485String, SendRS485Bool, SendRS485Number, TextOut, and Wait functions.

// RS-485 sender program
inline void WaitForMessageToBeSent()
{
}
task main()
{
// configure the S4 port as RS485
// make sure the RS485 system is turned on
// initialize the UART to default values
// low level API function call (allows changing UART settings)
// // hi level API function call
// RS485Initialize();
Wait(MS_1); // make sure everything gets turned on okay
int i;
byte buffer[];
while (true) {
string msg;
msg = "goofy " + NumToStr(i);
TextOut(0, LCD_LINE1, msg);
// send the # of bytes (5 bytes)
byte cnt = ArrayLen(msg);
WaitForMessageToBeSent();
// wait for ACK from recipient
RS485Read(buffer);
// now send the message
WaitForMessageToBeSent();
// wait for ACK from recipient
RS485Read(buffer);
i++;
}
// disable RS485 (not usually needed)
}