mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
24 4
MikroElektronika:
Development
tools
-
Books
-
Compilers
page
Prototype
void RS485Master_Init(void);
Description Initializes PIC MCU as Master in RS-485 communication.
Requires USART HW module needs to be initialized. See USART_Init.
Example
RS485Master_Init();
RS485Master_Init
Prototype
void RS485Master_Receive(char *data);
Description Receives any message sent by Slaves. Messages are multi-byte, so this function must be
called for each byte received (see the example at the end of the chapter). Upon receiving
a message, buffer is filled with the following values:
data[0..2] is the message,
data[3] is number of message bytes received, 1–3,
data[4] is set to 255 when message is received,
data[5] is set to 255 if error has occurred,
data[6] is the address of the Slave which sent the message.
Function automatically adjusts
data[4] and data[5] upon every received message.
These flags need to be cleared from the program.
Requires MCU must be initialized as Master in RS-485 communication in order to be assigned an
address. See
RS485Master_Init.
Example
unsigned short msg[8];
...
RS485Master_Receive(msg);
RS485Master_Receive