User manual
560
mikoPascal PRO for PIC32
MikroElektronika
Library Example
This example demonstrates simple data exchange via UART. If MCU is connected to the PC, you can test the example
from the mikroPascal PRO for PIC32 USART communication terminal, launch it from the drop-down menu Tools ›
USART Terminal or simply click the USART Terminal Icon .
Copy Code To Clipboard
program UART1;
var uart_rd : byte;
begin
CHECON := 0x32;
AD1PCFG := 0xFFFF; // Congure AN pins as digital I/O
UART1_Init(56000); // Initialize UART module at 56000 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text(‘Start’);
UART1_Write(13);
UART1_Write(10);
while (TRUE) do // Endless loop
begin
if (UART1_Data_Ready() <> 0) then // If data is received
begin
uart_rd := UART1_Read(); // read the received data
UART1_Write(uart_rd); // and send data via UART
end;
end;
end.