The example shows the initialization, writing, and reading data from the transmitter and receiver of an UART module, respectively. The realization is carried out by using the mikroBasic compiler for dsPIC30F microcontrollers. Fig. 13-8 shows the electrical connection of an UART module to an RS-232 transiever and further connection to the serial port of a PC.
Fig. 13-8 Electrical connection of an UART module to an RS-232 transiever and further connection to the serial port of a PC.
program Uart1_Test dim rx1 as word main: Uart1_Init(9600) while TRUE if Uart1_Data_Ready = 1 then rx1 = Uart1_Read_Char() Uart1_Write_Char(rx1) end if wend end.