PIC16F877A8-bit PIC microcontroller with 40/44-pin packages
A classic controller for digital, analog and serial interfaces.
PIC16F877A is an eight-bit PIC microcontroller with a fourteen-bit instruction word, 8K words of Flash program memory and 33 I/O lines. Its five ports connect to timers, an eight-channel ADC, serial interfaces and two capture/compare/PWM modules. The PDIP and TQFP versions carry the same functional signals at different lead numbers. The selected PIC16F877A operates from 4.0 to 5.5 V and requires a configured external oscillator or clock source. Most instructions take four oscillator cycles; a 20 MHz clock therefore gives up to five million instruction cycles per second. Its Flash capacity is 8K instruction words, not simply 8 KB of byte-addressed program storage. The example uses 5 V, a 4 MHz crystal, an ICSP header and a current-limited LED on RB0. Firmware must configure analog selections, direction registers and oscillator configuration before ordinary GPIO behavior can be expected. All supply pins and the reset/programming path are included in the reference.
Click a lead or use the arrow keys. Top view
MCLR / VPP
Function
Active-low reset and high-voltage programming entry.
How to connect
10 kΩ pull-up to 5 V; route to ICSP VPP.
RA0 / AN0
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
Analog/comparator functions can override digital I/O; configure ADCON1 and CMCON.
RA1 / AN1
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
Analog/comparator functions can override digital I/O; configure ADCON1 and CMCON.
RA2 / AN2 / VREF−
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
Analog/comparator functions can override digital I/O; configure ADCON1 and CMCON.
RA3 / AN3 / VREF+
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
Analog/comparator functions can override digital I/O; configure ADCON1 and CMCON.
RA4 / T0CKI
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
RA4 is open-drain as an output and needs an external pull-up for HIGH.
RA5 / AN4 / SS
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
RA5 is input-only as digital GPIO; do not use it as a push-pull output.
RE0 / AN5 / RD
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
Analog/comparator functions can override digital I/O; configure ADCON1 and CMCON.
RE1 / AN6 / WR
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
Analog/comparator functions can override digital I/O; configure ADCON1 and CMCON.
RE2 / AN7 / CS
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
Analog/comparator functions can override digital I/O; configure ADCON1 and CMCON.
VDD
Function
Positive supply; both VDD contacts must be connected.
How to connect
Connect regulated 5 V and local 100 nF bypass.
VSS
Function
Ground return; both VSS contacts must be connected.
How to connect
Common ground plane.
OSC1 / CLKI
Function
External crystal, resonator or clock connection selected by configuration bits.
How to connect
Example uses a 4 MHz crystal between OSC1 and OSC2 with suitable load capacitors.
OSC2 / CLKO
Function
External crystal, resonator or clock connection selected by configuration bits.
How to connect
Example uses a 4 MHz crystal between OSC1 and OSC2 with suitable load capacitors.
RC0 / T1OSO
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RC1 / T1OSI / CCP2
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RC2 / CCP1
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RC3 / SCK / SCL
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RD0 / PSP0
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RD1 / PSP1
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RD2 / PSP2
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RD3 / PSP3
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RC4 / SDI / SDA
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RC5 / SDO
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RC6 / TX / CK
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RC7 / RX / DT
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RD4 / PSP4
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RD5 / PSP5
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RD6 / PSP6
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RD7 / PSP7
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
VSS
Function
Ground return; both VSS contacts must be connected.
How to connect
Common ground plane.
VDD
Function
Positive supply; both VDD contacts must be connected.
How to connect
Connect regulated 5 V and local 100 nF bypass.
RB0 / INT
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Example LED through 1 kΩ to ground.
RB1
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RB2
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RB3 / PGM
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
Electrical note
PGM is low-voltage programming entry when LVP is enabled; define its level.
RB4
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RB5
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Use voltage-compatible inputs and define unused input states.
RB6 / PGC
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Route to ICSP programmer with a common ground.
RB7 / PGD
Function
Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection.
How to connect
Route to ICSP programmer with a common ground.
NC
Function
Additional unused lead in the TQFP package.
How to connect
Leave open.
NC
Function
Additional unused lead in the TQFP package.
How to connect
Leave open.
NC
Function
Additional unused lead in the TQFP package.
How to connect
Leave open.
NC
Function
Additional unused lead in the TQFP package.
How to connect
Leave open.
At a glance
8-bit PIC microcontroller with 40/44-pin packages
The CPU executes from Flash while ports, timers and analog logic expose controlled connections to the board.
Operating profile
PIC16F877A-I/P
CPU and memories
Key parameters and their test conditions
- Program Flash
- 8192 × 14-bit wordsConditions / notes: Harvard program memory
- Data RAM
- 368 bytesConditions / notes: Banked register address space
- Data EEPROM
- 256 bytesConditions / notes: Nonvolatile application data
- CPU instruction set
- 35 instructionsConditions / notes: Most take one instruction cycle
- Instruction clock
- FOSC / 4Conditions / notes: Branches normally take two instruction cycles
- Maximum oscillator
- 20 MHzConditions / notes: Up to 5 million instruction cycles per second
Package details
Follows the selected physical package
- Manufacturer
- Microchip Technology
- Part number
- PIC16F877A-I/P
- Package
- PDIP-40
- Connections
- 40 pins
- Mounting
- Through-hole
- Lead pitch
- 2.54 mm
- Package code
- PDIP-40
- Thermal reference
- See operating and package limits
Connections by function
Select a pin to open its function, electrical notes and wiring guidance.
Reset / program voltage1 pins
Analog and digital multiplexing9 pins
All supply and return pins4 pins
External oscillator2 pins
GPIO and digital peripherals24 pins
GPIO and digital peripherals24 pins
All supply and return pins4 pins
Unconnected TQFP leads4 pins
Reset / program voltage1 pins
Analog and digital multiplexing9 pins
External oscillator2 pins
Connect all supplies
Both VDD and both VSS pins must be wired.
Provide a clock
Match the oscillator configuration to the crystal or clock source.
Program and configure
Use ICSP, then set port and analog functions explicitly.
FOSC = 4 MHz gives a nominal instruction clock of 1 MHz. A 500 ms output toggle produces a 1 Hz full blink cycle.
Pin reference
Select a pin to explore its function and connection.
| Pin | Signal | Type | Function |
|---|---|---|---|
| MCLR / VPP | Reset / programming | Active-low reset and high-voltage programming entry. | |
| RA0 / AN0 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RA1 / AN1 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RA2 / AN2 / VREF− | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RA3 / AN3 / VREF+ | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RA4 / T0CKI | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RA5 / AN4 / SS | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RE0 / AN5 / RD | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RE1 / AN6 / WR | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RE2 / AN7 / CS | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| VDD | Supply | Positive supply; both VDD contacts must be connected. | |
| VSS | Supply | Ground return; both VSS contacts must be connected. | |
| OSC1 / CLKI | Clock | External crystal, resonator or clock connection selected by configuration bits. | |
| OSC2 / CLKO | Clock | External crystal, resonator or clock connection selected by configuration bits. | |
| RC0 / T1OSO | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RC1 / T1OSI / CCP2 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RC2 / CCP1 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RC3 / SCK / SCL | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RD0 / PSP0 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RD1 / PSP1 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RD2 / PSP2 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RD3 / PSP3 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RC4 / SDI / SDA | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RC5 / SDO | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RC6 / TX / CK | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RC7 / RX / DT | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RD4 / PSP4 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RD5 / PSP5 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RD6 / PSP6 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RD7 / PSP7 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| VSS | Supply | Ground return; both VSS contacts must be connected. | |
| VDD | Supply | Positive supply; both VDD contacts must be connected. | |
| RB0 / INT | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RB1 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RB2 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RB3 / PGM | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RB4 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RB5 | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RB6 / PGC | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| RB7 / PGD | GPIO / peripheral | Multiplexed GPIO and the named peripheral functions; configure direction and peripheral selection. | |
| NC | No connection | Additional unused lead in the TQFP package. | |
| NC | No connection | Additional unused lead in the TQFP package. | |
| NC | No connection | Additional unused lead in the TQFP package. | |
| NC | No connection | Additional unused lead in the TQFP package. |
No pins match. Try a signal name or choose All pins.
CPU and memories
Selected PIC16F877A
| Parameter | Value | Conditions / notes |
|---|---|---|
| Program Flash | 8192 × 14-bit words | Harvard program memory |
| Data RAM | 368 bytes | Banked register address space |
| Data EEPROM | 256 bytes | Nonvolatile application data |
| CPU instruction set | 35 instructions | Most take one instruction cycle |
| Instruction clock | FOSC / 4 | Branches normally take two instruction cycles |
| Maximum oscillator | 20 MHz | Up to 5 million instruction cycles per second |
No specifications match. Try a parameter name or a unit.
Account for bank selection and read-modify-write behavior in low-level code.
Supply and reset
F variant, industrial grade
| Parameter | Value | Conditions / notes |
|---|---|---|
| VDD | 4.0–5.5 V | Use regulated 5 V |
| PDIP supply pins | VDD11/32; VSS12/31 | Connect and bypass both pairs |
| TQFP supply pins | VDD7/28; VSS6/29 | Different lead numbers |
| MCLR / VPP | PDIP1; TQFP18 | Reset pull-up and ICSP entry |
| Reset source | Power-on, brown-out, watchdog, MCLR | Configuration and operating conditions apply |
| Temperature | −40 to +85°C | I-grade orderables |
No specifications match. Try a parameter name or a unit.
Do not substitute PIC16LF877A low-voltage specifications.
GPIO details that matter
Peripheral selection changes pin behavior
| Parameter | Value | Conditions / notes |
|---|---|---|
| Ports A/B/C/D/E | 6 / 8 / 8 / 8 / 3 lines | 33 I/O lines total |
| TRIS bit | 1 input, 0 output | Initialize the output latch before enabling output |
| RA4 | Open-drain output | External pull-up required for HIGH |
| RA5 | Input-only digital function | Also AN4 / SS / comparator output function |
| PORTA / PORTE | Analog functions after reset | Configure ADCON1 for digital use |
| Comparators | CMCON controls mode | CMCON = 0x07 disables comparators |
| PORTB pull-ups | Software-enabled weak pull-ups | For input-configured pins |
No specifications match. Try a parameter name or a unit.
The special comparator alternate function does not make RA5 a normal digital output.
ADC and analog configuration
10-bit successive approximation ADC
| Parameter | Value | Conditions / notes |
|---|---|---|
| Channels | AN0–AN7 | Pins multiplexed with ports A and E |
| Reference | VDD/VSS or external references | Selected by ADCON1 |
| Acquisition | Allow input capacitor to settle | Depends on source impedance and conditions |
| Conversion clock | Choose a valid TAD | Depends on FOSC and ADC clock selection |
| All-digital example | ADCON1 = 0x06 | No external analog reference in the LED example |
| Result registers | ADRESH / ADRESL | Justification is configurable |
No specifications match. Try a parameter name or a unit.
Resolution is not the same as accuracy; stay within input/reference limits.
Timers and communication
Hardware functions
| Parameter | Value | Conditions / notes |
|---|---|---|
| Timer0 | 8-bit | Prescaler and external T0CKI option |
| Timer1 | 16-bit | External oscillator / clock options |
| Timer2 | 8-bit plus period register | PWM timebase |
| CCP1 / CCP2 | Capture, compare and PWM | RC2 / RC1 default functions |
| MSSP | SPI or I²C | Shared serial pins |
| USART | Synchronous / asynchronous | RC6 TX/CK and RC7 RX/DT |
| Parallel slave port | PORTD with PORTE controls | Not active during ordinary GPIO use |
No specifications match. Try a parameter name or a unit.
Select one compatible function for each shared pin.
Programming and configuration
ICSP wiring and startup choices
| Parameter | Value | Conditions / notes |
|---|---|---|
| PDIP ICSP | VPP1, PGC39, PGD40 | Also VDD and VSS |
| TQFP ICSP | VPP18, PGC16, PGD17 | Same functions, different numbers |
| Low-voltage program pin | RB3 / PGM | Define its level or disable LVP deliberately |
| 4 MHz crystal example | XT oscillator mode | Load capacitors depend on the crystal |
| Watchdog | Enable or disable intentionally | An unserviced enabled watchdog resets the application |
| No internal system RC | External clock hardware required | Do not copy a newer PIC internal-oscillator setup |
No specifications match. Try a parameter name or a unit.
Use a compatible programmer; VPP is a programming voltage, not an ordinary logic input.
Minimal LED example
PDIP-40, 5 V, 4 MHz
| Parameter | Value | Conditions / notes |
|---|---|---|
| VDD / VSS | 11 and 32 / 12 and 31 | 100 nF at each supply pair |
| MCLR1 | 10 kΩ pull-up to 5 V | Preserve ICSP access |
| Crystal | 4 MHz between OSC1-13 and OSC2-14 | Example load capacitors 22 pF each; calculate for the crystal |
| RB0 pin 33 | 1 kΩ then red LED to ground | Nominal 3 mA at ideal 5 V and 2 V LED |
| Firmware setup | ADCON1 0x06; CMCON 0x07 | TRISB0 output, known latch state |
| Blink | Toggle every 500 ms | 1 Hz full cycle with correct clock configuration |
No specifications match. Try a parameter name or a unit.
The circuit needs firmware; the displayed readings are illustrative.
Control panels
Multiple digital ports and interfaces.
Manufacturer application guideAnalog instruments
Sample several analog inputs.
Manufacturer application guideMotor and timing control
Use PWM with an external power driver.
Manufacturer application guideTake it into ProTech
Find PIC16F877A in the Components Library to place its schematic symbol and connect its pins.
Reference page · circuit simulation model not yet availableOpen ProTech
