This is a small example shows how to use PIC16F877A UART module using CCS PIC C compiler.
PIC16F877A UART connection circuit schematic:
Pin RC6 (TX) and pin RC7 (RX) are used for the UART (serial) communication between the microcontroller and the computer. To change between TTL logic levels (5V) and RS232 signals (+/-12V), an IC is needed which is max232.
Don’t connect TX and RX pins directly to an RS232 serial port which may damage your microcontroller.
CCS C compiler serial monitor can be used to communicate with the microcontroller.
PIC16F877A UART example CCS C code:
This is the full C code for this example.
Serial Rs232 Cable


Serial Rs232 To Usb
2 4 6 8 10 12 14 16 18 20 22 24 | #fuses HS,NOWDT,NOPROTECT,NOLVP #use rs232(uart1, baud = 9600) // Initialize UART module chari; putc(13);// Go to first column delay_ms(5000);// Wait 5 seconds putc(10);// Start a new line putc(13);// Go to first column while(TRUE){ i=getc();// UART read } } |
Comunicacion Serial Rs232 Pic Ccs 2019
PIC16F877A UART example video: