Mikroelektronika MIKROE-724 データシート

ページ / 726
622
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
UARTx_Init
Prototype
sub procedure UARTx_Init(dim baud_rate as longint)
Description Configures and initializes the UART module.
The internal UART module module is set to: 
- continue operation in IDLE mode 
- default Tx and Rx pins 
- loopback mode disabled 
- 8-bit data, no parity 
- 1 STOP bit 
- transmitter enabled 
- generate interrupt on transmission end 
- interrupt on reception enabled 
- Address Detect mode disabled 
Parameters 
baud_rate
: requested baud rate 
Returns
Nothing.
Requires
Routine requires the UART module.
Example
‘ Initialize hardware UART1 module and establish communication at 2400 bps
UART1_Init(2400)
Notes
Refer to the device data sheet for baud rates allowed for specific Fosc.
For the dsPIC33 and PIC24 MCUs, the compiler will choose for which speed the calculation is to be 
performed (high or low). This does not mean that it is the best choice for desired baud rate. 
If the baud rate error generated in this way is too big then UARTx_Init_Advanced routine, which allows 
speed select be used.
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.