Datasheet

UARTx_Init_Advanced
UARTx_Data_Ready
479
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure UARTx_Init_Advanced(baud_rate : dword; parity : byte;
byte);
Returns Nothing.
Description
Configures and initializes UART module.
Parameter baud_rate configures UART module to work on a requested baud rate.
Parameters parity and stop_bits determine the work mode for UART, and can
have the following values:
Note: Some MCUs do not support advanced configuration of the UART module.
Please consult appropriate daatsheet.
Requires MCU must have UART module.
Example
// Initialize hardware UART1 module and establish communication
at 9600 bps, 8-bit data, even parity and 2 STOP bits
UART1_Init_Advanced(9600, _UART_EVENPARITY, _UART_TWO_STOPBITS);
Mask Description Predefined library const
Parity constants:
0x00 Parity mode disabled _UART_NOPARITY
0x20 Even parity _UART_EVENPARITY
0x30 Odd parity _UART_ODDPARITY
Stop bit constants:
0x00 1 stop bit _UART_ONE_STOPBIT
0x01 2 stop bits _UART_TWO_STOPBITS
Prototype
function UARTx_Data_Ready(): byte;
Returns Function returns 1 if data is ready or 0 if there is no data.
Description The function tests if data in receive buffer is ready for reading.
Requires
MCU with the UART module.
The UART module must be initialized before using this routine. See the
UARTx_Init routine.
Example
var receive: byte;
...
// read data if ready
if (UART1_Data_Ready() = 1) then
receive := UART1_Read();