This tutorial is designed for the beginners who are new to the world of Microcontrollers, to provide a little know-how about the technology. PIC (Peripheral Interface Controller) family are popular among students, hobbyists and also the industrial developers due to its low cost, serial programming capability and its ease of availability. The 8-bit PIC microcontrollers are divided into four large families based on their built-in special features:

  • PIC10FXXX series
  • PIC12FXXX series
  • PIC16FXXX series
  • PIC18FXXX series

Let’s just take the example of a single PIC microcontroller from the PIC 16FXXX family for this document. At the end of this document, you would have gained enough knowledge to work with the other standard MCUs of PIC16FXXX family as well, as they all have similar architecture.

PIN OUTS OF PIC16F877A microcontroller

PIC16F877A is one of the most widely used controllers. The pin configuration of the MCU and some of its functions are illustrated below. It is a 40-pin DIP Microcontroller (also available in other packages).

pin out of PIC16F8777A pic microcontrollers
pin out of PIC16F8777A pic microcontrollers

Standard Requirements

Vdd (pwr) and Vss (gnd) needs to be hooked up with power and ground respectively. Pin 1 is the MCLR pin for the program restart feature. It must be tied to the Vdd with a pull-up resister in between.Since PIC16F877A does not have an internal oscillator so you need to have an external crystal connected across pin 13 and 14.

There are 5 ports in PIC16F877A with ports A and E having fewer pins than ports B, C and D. These are called the digital I/O pins.CCP1 and CCP2, shared with the I/O pins RC1 and RC2, can be used to generate PMW signals with the microcontroller. PGC and PGD pins are used for programming and debugging.

Ports and Registers

PortA and TRISA

PortA is a bi-directional port, having 6-bit (A0-A5). The TRISA register is used to determine the status of the corresponding port, i.e. whether it is working as an input port or an output port. If TRISA bit=1, the corresponding port pin is set as input. If TRISA bit=0, the corresponding port pin is set as output. Most of the portA pins are multiplexed with the analog input pins used for A/D converters. Make sure TRISA is set to 1 when using it as an analog input.

This information comes in handy when writing the programming code.

PortB and TRISB

PortB is a bi-directional port, having 8-bit (B0-B7) and TRISB is its data direction register. A bit in PortB is set as input if its corresponding TRISB bit is equal to 1. Whereas if the TRISB bit is cleared, then the corresponding PortB bit will be set as output. RB6 and RB7 are multiplexed with the PGC and PGD functions that are used for programming and debugging.

PortC and TRISC

Just like PortA and PortB, PortC is an 8-bit, bi-directional port. TRISC bit=1 sets the corresponding PortC bit as input and TRISC bit=0 sets the corresponding PortC bit as output. PortC is also multiplexed with many peripheral functions.

PortD and TRISD

PortD is alsoan 8-bit, bi-directional port. Each pin in PortD is individually configurable as input or output. It can be configured as Parallel Slave Port if the 4-bit of TRISE (PSPMODE) is set to 1.

PortE and TRISE

PortE has only 3-bits (E0-E2) which are also individually configurable as input or output. All 3 PortE pins are multiplexed with analog inputs.

Timers and Counters

PIC Microcontrollers have a built-in precise timing system called timers/counters which can be used to perform several tasks such as generating timing signals, calculating the span of an event, keeping record of date and time and so on. Since the counter runs independently, it can count the instruction cycles simultaneously with the main program execution. PIC16F877A consists of 3 timer modules:

  • TIMER0
  • TIMER1
  • TIMER2

 This tutorial gives you the basic knowledge required to get started with PIC Microcontrollers. The tutorials to follow next include:

We are going to post series of tutorials on above mentioned articles. keep visiting our website for more information about above mentioned articles. This is all effort from our side, kindly share this article or website with your friends. That’s what you can do us right now. Thanks 🙂  You may also like to check Pic microcontroller projects


  1. It really seems very useful to the begginners to learn the embedded and the PIC controllers, if it had been a visual learning itwould have been a better opputunity


Leave a Comment