PIC16F877 UART code and Proteus simulation

This post answers the question, “How to use interrupt based UART in PIC16F877” ?

Also, using PIC16 simulator (Proteus) you can verify this UART code and change it according to your needs. This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the ‘Downloads‘ section at the bottom of this page.

This PIC16F877 microcontroller tutorial provides the interrupt based UART functions which you can easily understand and use. After reading this page you can easily use PIC16F877 serial UART interface.

It is assumed that you know how to blink an LED with PIC16F877 microcontroller. If you don’t then please read this page first, before proceeding with this article.

The following diagram (made in Proteus) shows the PIC microcontroller circuit diagram.

PIC16F877 UART schematic

In the above figure, UART baudrate is currently set to 9600 bps, but you can change it to your desired value. RC6 pin is the TX pin and RC7 pin is the RX pin the UART. Whenever a new character is received on the UART, then PIC16F877 goes into interrupt service routine and received character is echoed back.

When code starts to execute then PIC16F877 sends ‘Hello World‘ to virtual terminal. After that PIC16F877 echos back whatever character is sent to it. ‘Hi’ was typed in the virtual terminal after the start up of the simulation in Proteus and PIC16F877 echoed it back.


The code used to set different properties of UART is shown below. (From UART.h file)


UART code for PIC16F877 was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.


For more detail: PIC16F877 UART code and Proteus simulation

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.