Mikroelektronika MIKROE-742 데이터 시트
RS485Master_Init
340
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure RS485Master_Init();
Returns
Nothing.
Description
Initializes MCU as a Master for RS-485 communication.
Requires
Global variables :
-
RS485_rxtx_pin
- this pin is connected to RE/DE input of RS-485
transceiver(see schematic at the bottom of this page). RE/DE signal controls
RS-485 transceiver operation mode.
RS-485 transceiver operation mode.
-
RS485_rxtx_pin_direction
- direction of the RS-485 Transmit/Receive pin
must be defined before using this function.
UART HW module needs to be initialized. See UARTx_Init.
Example
// RS485 module pinout
var RS485_rxtx_pin : sbit at PORTD.B2;
var RS485_rxtx_pin_direction : sbit at DDRD.B2;
// End of RS485 module pinout
var RS485_rxtx_pin : sbit at PORTD.B2;
var RS485_rxtx_pin_direction : sbit at DDRD.B2;
// End of RS485 module pinout
// Pass pointers to UART functions of used UART module
UART_Wr_Ptr := @UART1_Write;
UART_Rd_Ptr := @UART1_Read;
UART_Rdy_Ptr := @UART1_Data_Ready;
UART_Rdy_Ptr := @UART1_Data_Ready;
UART_TX_Idle_Ptr := @UART1_TX_Idle;
...
...
UART1_Init(9600); // initialize UART module
RS485Master_Init(); // intialize MCU as a
Master for RS-485 communication
Master for RS-485 communication