Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
Don't worry -- youre-mail address is totally secure. I promise to use it only to send you MicroZine.

The popular 16F877A.

The 16F877A is one of the most popular PIC microcontrollers and it's easy to see why - it comes in a 40 pin DIP pinout and it has many internal peripherals.

The only disadvantage that you could level at it is that it does not have an internal clock source like most of the other more modern PIC's. However using an external clock usually results in faster operation since you can select a 20MHz crystal instead of the usual internal 8MHz oscillator.

The 16F877A is a capable microcontroller that can do many tasks because it has a large enough programming memory (large in terms of sensor and control projects) 8k words and 368 Bytes of RAM. This is enough to do many different projects (see links at end of this page for some example projects on this site).

Note: There is a more modern part (the 16F887) that has nearly the same functionality as the 16F877A but also includes an internal clock - like the 16F88 and the 18F4550. In addition the 16F887 also has low power operation using nano wattTM technology.

Differences Between 16F877A and 16F887

Interface 16F877A 16F887 Description
RA4/T0CKI Open drain Normal CMOS The pin is physically different so the input characteristics are changed.
Cost Expensive Cheaper Modern devices are usually cheaper.
ADC Yes More useful More controls although different registers are used.
Nano WattTM No Yes 16F88x - ultra low power operation (battery operation).
Internal Clock No Yes 8Mhz to 31kHz 1% accuracy.
External Gate No Yes External Timer1 gate input (start Timer1 counter).
Volt reference No Yes Internal 0.6V voltage reference.
RS485, LIN 2.0 No Yes Enhanced USART supports RS485 and LIN 2.0 operation.
Parallel Slave port Yes No Acts as an 8 -bit processor interface i.e. another 8 bit processor can read and write to this interface controlling the 16F877A as a slave processor.

The four features that you might make you use a 16F887 instead of a 16F877(A) are

  • External gate.
  • Volt Reference.
  • Nano WattTM.
  • Internal Clock.

The gate could be used to more accurately capture an input time e.g. for a reciprocal frequency counter.

The volt reference means you don't need an external reference although it will probably not be useful for highly accurate operation. It is definitely more useful in a battery powered operation where you want to compare the input battery voltage to a known reference e.g. using the comparator and the internal 0.6V reference.

Nano WattTM could be useful for battery powered operation.

The internal clock is useful for lab development (not for accuracy) and for general operation - it can also be set to 31kHz so consuming less power.

All the above depend on your specific application requirements.


The 40 pins make it easier to use the peripherals as the functions are spread out over the pins.  This makes it easier to decide what external devices to attach without worrying too much if there are enough pins to do the job.  

One of the main advantages is that each pin is only shared between two or three functions so its easier to decide what the pin function (other devices have up to 5 functions for a pin).

A slight disadvantage of the device is that it has no internal oscillator so you will need an external crystal or other clock source. However the internal oscillator is only 1% accurate and adding a crystal (max 20MHz crystal - for 5MHz internal instruction cycle) and two 15pF capacitors is not a great chore - the accuracy will be 100ppm depending on the crystal used.


The pinout of the 16F877A is:

chip pinout PIC16F877A

Internal Peripherals

PIC16F877A at a glance

As you can see the chip is full of peripherals so you can use it for many different projects.

The main peripherals of the 16F877A are:

  • 2 CCP modules Capture Compare PWM (select one of three operations).
  • 2 Analogue comparators.
  • A Serial interface (either I2C or SPI operation).
  • A USART Universal Synchronous Asynchronous Transmitter Receiver (Rs232 interface).
  • 3 Timers.
  • 1 ADC Analogue to Digital Converter with multiplexor for 10 inputs.
  • 33 I/O pins.
  • 8192 Program words of re-programmable FLASH memory.
  • 368 Bytes of RAM.
  • 256 Bytes of EEPROM.
  • A Parallel Slave Port.

As you can see the device has a rich set of internal peripherals that can be used for many different designs.

The most unusual internal peripheral is the parallel Slave Port (PSP) and this makes the device compatible with an 8 bit bus so you can directly interface the 16F877A into a system that uses an 8 bit bus. Although this is probably not common now you could enhance an existing system by adding this device i.e. enhance by adding the capabilities of all the other internal peripherals.

More 16F877/A Projects:

8 Digit 7 Segment
Frequency Counter

RS232 Serial LCD


Jump to other devices:  bubble diagram device list.


  1. Home Page Name
  1. Best Microcontroller Projects

New! Comments

Have your say about what you just read! Leave me a comment in the box below.

Privacy Policy | Contact | About Me

Site Map | Terms of Use

Visit our Facebook Page:

   Click Here

Recent Articles

  1. PIC PWM: Easy Pulse width Modulation on the PIC Micro.

    PIC PWM : What its for and how to use it. Including an example showing typical setup of a PIC PWM module with register settings.

    Read more

  2. The Essential I2C Tutorial: All you need to know about I2C...

    How to use I2C. In this tutorial you will learn all about the 2 wire I2C serial protocol. Learn how easy it is to use, how it works and when to use it...

    Read more

  3. PIC LCD volt meter : How to use the ADC for voltage measurement.

    A 0-5V LCD volt meter project using an HD44870 display and one PIC micro ADC.

    Read more

  4. PIC Programming using ICSP

    PIC programming : How to use ICSP for programming a PIC microcontroller giving some ICSP connection diagrams and it also shows how to use MPLAB X and ICPROG.

    Read more

  5. PIC ICSP In Circuit Serial Programming

    How to program PIC ICSP, IN-Circuit, live and still have a working programmer and operational circuit!

    Read more

  6. An Ultrasonic Distance meter project: How to make one using a microcontroller.

    Understand how an Ultrasonic Distance meter works by building one your self – including Free software to drive the microcontroller and display.

    Read more

Sign up for MicroZine
''The'' Microcontroller Newsletter

Enter your first Name and primary email address in the form below:

And receive absolutely FREE a full project for:

"Measuring Analogue Voltages
Without An ADC"

(Using only one pin).

Instant Download:
You Can
Get It Right Now

Warning: This project could be  Removed 
at any time.  

It will  NOT be 
available indefinitely SO
To avoid 
disappointment  get it:


Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.

To get exclusive access Enter your first name Name and primary email address Now in the form above.:

But wait !

There's more...

You'll receive more
free and exclusive reports as well as site information and site product updates

Scroll up to the form above and sign up NOW. Don't forget it's FREE and if you don't like it, you can unsubscribe at any time.

Click Here Now to use the form above to get your Valuable information absolutely free.

Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's


- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan


"Awesome site,
very, very easy and nice
to navigate!"

- Matt

Learn Microcontrollers

"Interested in

Sign up for The
Free 7 day guide:


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."

- Dave


"Your site is a great
and perfect work.

- Suresh


"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.

- Anon

Back to Top