PIC12F675 interrupt based software UART code and Proteus simulation

This post provides the interrupt based software UART (Bit Banging) code for PIC12F675 microcontroller.

PIC12F675 interrupt based software UART

As we know, PIC12F675 microcontroller doesn’t have built in UART module, so we can create UART functionality in it’s software. This post provides the details of how to program software UART functionality in PIC12F675. 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.

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

The result of simulating the code in Proteus is shown below.

In the above figure, UART baudrate is currently set to 1200 bps, but you can change it to your desired value. GP0 pin is being used as TX pin and GP2 pin is the RX pin of the software UART. External interrupt on pin GP2 is enabled in the code. Whenever a high to low transition is received on GP2 pin (i-e starting bit for UART) then PIC12F675 goes into interrupt service routine and received character is echoed back.

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

PIC12F675 interrupt based software UART


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

In the above figure, _XTAL_FREQ is defined to be 4000000, which is the internal oscillator frequency of PIC12F675. If you change the crystal (e-g by attaching an external crystal of different frequency) then you will need to change _XTAL_FREQ value as well. For example, if 12MHz external crystal is used, then _XTAL_FREQ should be defined as 12000000 in the above code.


Interrupt based software UART code for PIC12F675 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: PIC12F675 interrupt based software 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.