Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
RS-485 LIBRARY
RS-485 is a multipoint communication which allows multiple devices to be connect-
ed to a single bus. The mikroPascal PRO for AVR provides a set of library routines
for comfortable work with RS485 system using Master/Slave architecture. Master
and Slave devices interchange packets of information. Each of these packets con-
tains synchronization bytes, CRC byte, address byte and the data. Each Slave has
unique address and receives only packets addressed to it. The Slave can never ini-
tiate communication.
It is the user’s responsibility to ensure that only one device transmits via 485 bus at a time.
The RS-485 routines require the UART module. Pins of UART need to be attached
to RS-485 interface transceiver, such as LTC485 or similar (see schematic at the
bottom of this page).
Library constants: 
- START byte value = 150 
- STOP byte value = 169 
- Address 50 is the broadcast address for all Slaves (packets containing address 50 
will be received by all Slaves except the Slaves with addresses 150 and 169). 
Note: 
- Prior to calling any of this library routines, UART_Wr_Ptr needs to be initialized 
with the appropriate UART_Write routine. 
- Prior to calling any of this library routines, UART_Rd_Ptr needs to be initialized 
with the appropriate UART_Read routine. 
- Prior to calling any of this library routines, UART_Rdy_Ptr needs to be initialized 
with the appropriate UART_Ready routine. 
- Prior to calling any of this library routines, UART_TX_Idle_Ptr needs to be initiali-
zed with the appropriate UART_TX_Idle routine. 
338
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6