RS232 serial communication
This example illustrates the use of the microcontroller’s EUSART module. Connection between the microcontroller and a PC is established in compliance with the RS232 communication standard. The program works as follows. Every byte received via serial communication is displayed using LED diodes connected to PORTB and is automatically sent back to the sender thereupon. The easiest way to test the program operation is by using a standard Windows program called Hyper Terminal.' Header****************************************************** program example_11 ' Program name dim i as byte ' Variable is of byte type main: ' Start of program UART1_Init(19200) ' Initialize USART module ' (8 bit, 19200 baud rate, no parity bit...) while 1 ' Endless loop if UART1_Data_Ready() then ' If data has been received i = UART1_Read() ' read it UART1_Write(i) ' and send it back end if wend end. ' End of programIn order to make this example work properly, it is necessary to check the UART library in the Library Manager prior to compiling: