ABL electronic PIC16 Personal Computer User Manual


 
MikroElektronika:
Development
tools
-
Books
-
Compilers
24 5
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Prototype
void RS485Master_Send(char *data, char datalen, char address);
Description Sends data from buffer to Slave(s) specified by address via RS-485; datalen is a
number of bytes in message (1 <= datalen <= 3).
Requires MCU must be initialized as Master in RS-485 communication in order to be assigned an
address. See RS485Master_Init.
It is programmer’s responsibility to ensure (by protocol) that only one device sends data
via 485 bus at a time.
Example
unsigned short msg[8];
...
RS485Master_Send(msg, 3, 0x12);
RS485Master_Send
Prototype
void RS485Slave_Init(char address);
Description Initializes MCU as Slave with a specified address in RS-485 communication. Slave
address can take any value between 0 and 255, except 50, which is common address
for all slaves.
Requires USART HW module needs to be initialized. See USART_Init.
Example
RS485Slave_Init(160); // Initialize MCU as Slave with address 160
RS485Slave_Init