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 mikroC 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.
unsigned rx1; void main() { Uart1_Init(9600); Uart1_Write_Char('s'); while(1) { if (Uart1_Data_Ready()) { rx1 = Uart1_Read_Char(); Uart1_Write_Char(rx1); } } }