User`s manual
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
sub procedure RS485master_init
USART needs to be initialized (USART_init)
None
Initializes MCU as Master in RS485 communication
sub procedure RS485slave_init(dim address as byte)
USART needs to be initialized (USART_init)
Slave address can take any value between 0 and 255, except 50, which is common
address for all slaves)
Initializes MCU as Slave in RS485 communication
sub procedure RS485master_read(dim byref data as byte[5])
MCU must be initialized as Master to assign an address to MCU.
dim byref data as byte[5]
Master receives any message sent by Slaves. As messages are multi-byte, this pro-
cedure must be called for each byte received. Upon receiving a message, buffer is
filled with the following values:
data[0..2] is data; data[3] is the number of received bytes (1..3); data[4] is set to
255 (TRUE) when message is received; data[5] is set to 255 (TRUE) if an error
has occurred; data[6] is the address of the Slave which sent the message
Procedure automatically sets data[4] and data[5] upon every received
message.These flags need to be cleared repeatedly from the program.
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
151
page
RS485master_init
Prototype:
Parameters:
Effects:
Precondition:
RS485slave_init
Prototype:
Parameters:
Effects:
Precondition:
RS485master_read
Prototype:
Parameters:
Effects:
Precondition: