Mikroelektronika MIKROE-742 데이터 시트
![Mikroelektronika](https://files.manualsbrain.com/attachments/e0529b3b58069a916ad7bb89f7e9f5f0eda73421/common/fit/150/50/1b07b99aa3112e022a916b06db07f1f4f211e91d41878452d87c7638b1bf/brand_logo.gif)
RS485slave_Receive
RS485Slave_Send
344
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure RS485Slave_Receive(var data_buffer: array[20] of byte);
Returns
Nothing.
Description
Receives messages from Master. If Slave address and Message address field
don't match then the message will be discarded. Messages are multi-byte, so
this routine must be called for each byte received.
don't match then the message will be discarded. Messages are multi-byte, so
this routine must be called for each byte received.
Parameters :
-
data_buffer
: 6 byte buffer for storing received data, in the following manner:
-
data[0..2]
: message content
-
data[3]
: 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
The function automatically adjusts data[4] and data[5] upon every received mes-
sage. These flags need to be cleared by software.
sage. These flags need to be cleared by software.
Requires
MCU must be initialized as a Slave for RS-485 communication. See
RS485Slave_Init.
RS485Slave_Init.
Example
var msg : array[20] of byte;
...
...
RS485Slave_Read(msg);
Prototype
procedure RS485Slave_Send(var data_buffer: array[20] of byte;
datalen : byte);
datalen : byte);
Returns
Nothing.
Description
Sends message to Master. Message format can be found at the bottom of this page.
Parameters :
-
data_buffer
: data to be sent
-
datalen
: number of bytes for transmition. Valid values: 0...3.
Requires
MCU must be initialized as a Slave for
RS-485
communication. See
RS485Slave_Init
. It is the user’s responsibility to ensure (by protocol) that only
one device sends data via 485 bus at a time.
Example
var msg : array[8] of byte;
...
// send 2 bytes of data to the Master
...
// send 2 bytes of data to the Master
RS485Slave_Send(msg, 2);