User manual

mikroC PRO for dsPIC
MikroElektronika
465
Library Dependency Tree
The following variable must be
dened in all projects using RS-485
Library:
Description : Example :
extern sfr sbit RS485_rxtx_
pin;
Control RS-485 Transmit/
Receive operation mode
sbit RS485_rxtx_pin at RF2_bit;
extern sfr sbit RS485_rxtx_
pin_direction;
Direction of the RS-485
Transmit/Receive pin
sbit RS485_rxtx_pin_direction at
TRISF2_bit;
External dependencies of RS-485 Library
Library Routines
- RS485Master_Init
- RS485Master_Receive
- RS485Master_Send
- RS485Slave_Init
- RS485Slave_Receive
- RS485Slave_Send
RS485Master_Init
Prototype
void RS485Master_Init();
Description Initializes MCU as a Master for RS-485 communication.
Parameters None.
Returns Nothing.
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.
- RS485_rxtx_pin_direction - direction of the RS-485 Transmit/Receive pin.
must be dened before using this routine.
UART HW module needs to be initialized. See UARTx_Init.
Example
// RS485 module pinout
sbit RS485_rxtx_pin_direction at RF2_bit; // transmit/receive control set
to PORTC.B2
sbit RS485_rxtx_pin_direction at TRISF2_bit; // RxTx pin direction set as
output
// end RS485 module pinout
...
UART1_Init(9600); // initialize UART1 module
RS485Master_Init(); // intialize MCU as a Master
for RS-485 communication
Notes None