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.
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
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w
Current Project / Post can also be found using:
- UART in proteus
- uart proteus
- uart proteus Spanish
- usart pic microcontroller proteus