The example demonstrates simple data exchange via software UART. When PIC
MCU receives data, it immediately sends the same data back. If PIC is connected
to the PC (see the figure below), you can test the example from mikroC terminal
for RS232 communication, menu choice Tools > Terminal.
MikroElektronika:
Development
tools
-
Books
-
Compilers
26 3
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Library Example
unsigned short data = 0, ro = 0;
unsigned short *er;
void main() {
er = &ro;
// Init (8 bit, 2400 baud rate, no parity bit, non-inverted logic)
Soft_Uart_Init(&PORTB, 1, 2, 2400, 0);
do {
do {
data = Soft_Uart_Read(er);
// Receive data
} while (*er);
Soft_Uart_Write(data);
// Send data via UART
} while (1);
}
//~!