User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
597
UART_Set_Active
Prototype
void UART_Set_Active(unsigned (*read_ptr)(), void (*write_ptr)(unsigned
char _data), unsigned (*ready_ptr)(), unsigned (*tx_idle_ptr)());
Description Sets active UART module which will be used by UARTx_Data_Ready, UARTx_Read and UARTx_
Write routines.
Parameters Parameters:
- read_ptr: UARTx_Read handler
- write_ptr: UARTx_Write handler
- ready_ptr: UARTx_Data_Ready handler
- tx_idle_ptr: UARTx_Tx_Idle handler
Returns Nothing.
Requires Routine is available only for MCUs with multiple UART modules.
Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_
Advanced routines.
Example
UART1_Init(9600); // initialize UART1 module
UART2_Init(9600); // initialize UART2 module
RS485Master_Init(); // initialize MCU as Master
UART_Set_Active(&UART1_Read, &UART1_Write, &UART1_Data_Ready, &UART1_Tx_
Idle); // set UART1 active
RS485Master_Send(dat,1,160); // send message through UART1
UART_Set_Active(&UART2_Read, &UART2_Write, &UART2_Data_Ready, &UART2_Tx_
Idle); // set UART2 active
RS485Master_Send(dat,1,160); // send through UART2
Notes None.