mikroC
making it simple...
RS-485 Library
mikroC - C Compiler for Microchip PIC microcontrollers
RS-485 is a multipoint communication which allows multiple devices to be connected to a single signal cable. mikroC provides a set of library routines to provide you comfortable work with RS-485 system using Master/Slave architecture. Master and Slave devices interchange packets of information, each of these packets containing synchronization bytes, CRC byte, address byte, and the data. Each Slave has its unique address and receives only the packets addressed to it. Slave can never initiate communication. It is programmer’s responsibility to ensure that only one device transmits via 485 bus at a time.
RS-485 routines require USART module on PORTC. Pins of USART need to be attached to RS-485 interface transceiver, such as LTC485 or similar. Pins of transceiver (Receiver Output Enable and Driver Outputs Enable) should be connected to PORTC, pin 2 (check the figure at end of the chapter).
Note: Address 50 is the common address for all Slaves (packets containing address 50 will be received by all Slaves). The only exceptions are Slaves with addresses 150 and 169, which require their particular address to be specified in the packet.
Library Routines
RS485Master_Init
RS485Master_Receive
RS485Master_Send
RS485Slave_Init
RS485Slave_Receive
RS485Slave_Send
| | page | |
MikroElektronika: Development tools - Books - Compilers | 243 |
| |