User manual

624
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Returns Nothing.
Requires Routine requires the UART module.
Example
‘ dsPIC30 family example
Initialize hardware UART1 module and establish communication at 2400 bps,
8-bit data, even parity and 2 STOP bits
UART1_Init_Advanced(2400, 2, 1)
‘ dsPIC33 and PIC24 family example
Initialize hardware UART2 module and establish communication at 2400 bps,
8-bit data, even parity, 2 STOP bits and high speed baud rate calculations
UART2_Init_Advanced(2400, 2, 1, 1)
Notes Refer to the device data sheet for baud rates allowed for specic Fosc.
UART library routines require you to specify the module you want to use. To select the desired UART
module, simply change the letter x in the routine prototype for a number from 1 to 4.
Switching between the UART modules in the UART library is done by the UART_Set_Active function
(UART modules have to be previously initialized).
Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.
UARTx_Data_Ready
Prototype
sub function UARTx_Data_Ready() as word
Description The function tests if data in receive buffer is ready for reading.
Parameters None.
Returns - 1 if data is ready for reading
- 0 if there is no data in the receive register
Requires Routine requires at least one UART module.
Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_
Advanced routines.
Example
dim receive as word
...
‘ read data if ready
if (UART1_Data_Ready() = 1) then
receive = UART1_Read()
end if
Notes UART library routines require you to specify the module you want to use. To select the desired UART
module, simply change the letter x in the routine prototype for a number from 1 to 4.
Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.