SERIAL COMMUNICATION USING PIC16F877A MICROCONTROLLER, In this tutorial you will learn what is serial communication? What are applications of serial communication? How serial communication pins of PIC16F877A microcontroller is used to transmit and receive data to and from other devices. Lets start with basic introduction of serial communication.

What is serial communication ?

 Unlike parallel communication, where several bits are send at one time, Serial Communication is a process of transmitting data bit by bit. In this tutorial, you will learn how to serially communicate a PC or any other device with a PIC microcontroller. You will also study the use of a communication component – UART (Universal Asynchronous Receiver Transmitter) present within the microcontroller.


To perform serial communication using PIC16F877A

 Serial Communication is the process of sending data one bit at a time. It is achieved by using the UART feature within the pic microcontroller. UART (Universal Asynchronous Receiver Transmitter) is a serial communication interface which is used for transmitting and receiving data. The UART feature is first initialized and then it can be used for transferring data. One of the serial communication architecture includes RS232 standard. It is commonly used in computer serial ports. Using RS232 interface, the communication between a microcontroller and a PC or two microcontrollers can be made possible.


serial communication using pic microcontroller

serial communication using pic microcontroller

In order to make the communication possible between PIC and a PC, a DB9 connector (female) is used as shown in the schematic, whose male part is connected to the PC. The voltage levels of RS232 protocol are different from that of UART. The voltage level generally used in MCU is HIGH=5V and LOW=0V. Whereas the RS232 working voltages are HIGH=+12V and LOW=-12V.

In order to use the RS232 protocol, we will need a level converter. A level converter will convert the ±12V coming from PC into 5V which can be fed to the controller and vice versa. The level converter used here is called ICMAX232. All the connections of IC with the controller and also with the DB9 connector are shown in the circuit diagram above. RC6/TX and RC7/RX pins of the microcontroller are connected to the T1IN and R1OUT pins of the ICMAX232 respectively. Similarly, the T1OUT and R1IN pins of MAX232 are connected to the DB9 pins 2 (RX) and 3(TX) respectively. Pin 5 of the DB9 connector is grounded. A virtual terminal is connected to the RX and TX pics of the microcontroller to display the transmitting and receiving data.

Serial communication video lecture


 Write the following code in the Code Editor Window of mikroC compiler.

  1. char data_rd;
  2. void main() {
  3. UART1_Init(19200); // Initialize UART module at baud rate 19200 bps
  4. Delay_ms(100); // Wait for UART module to stabilize
  5. UART1_Write_Text(“Enter Data”);
  6. UART1_Write(10);// moving one line forward
  7. UART1_Write(13);// carriage return
  8. while (1) { // loop executed infinite times
  9. if (UART1_Data_Ready()) { // If data is received from PC
  10. data_rd = UART1_Read(); // read the received data
  11. UART1_Write(data_rd);  // send data via UART
  12. }
  13. }
  14. }

MikroCcompiler has built-in library routines for PIC UART that makes it possible to work with the Asynchronous mode comfortably.In the beginning of the code, a variable of type character – ‘data_rd’ has been declared which holds the value received from PC. You can use a terminal program on PC to transmit and receive data. The baud rate of UART is set to 19200bps in the program. 19200 is the number of bits sent over a serial line per second.The while loop receivesthe data from the PC, stores it in the variable ‘data_rd’ and then sends it again to the terminal on PC.

 APPLICATIONS of serial communication :

 In this day and age, serial communication is used in various industrial projects where data needs to be collected from different devices. HMI used in banks, marts, industries etc are also serially interconnected.

To download circuit diagram and code of serial communication tutorial using pic microcontroller,Click on following link. Kindly take few seconds to share this article with your friends on social media. Thanks 🙂

 Serial communication data


  1. zain August 16, 2015
  2. zain August 16, 2015
  3. Pravin February 3, 2017

Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 974 other subscribers