Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with PIC 16F877

Not open for further replies.


Advanced Member level 4
Mar 3, 2006
Reaction score
Trophy points
Activity points
configuration bits 16f877a problems


I am having problem with PIC16F877. First, I have simulated my program in Proteus and it works fine, so there is little chance of a programming problem. But in hardware, my controller works well if I touch it with hand(when I am connected to earth). Morover, I have tried the following:

1 - As I am using PORTC(PORTB and PORTD) of the PIC, I have tried both pulling it up and down, through a variety of resistors, but it did not give the right output.

2 - I have checked and re-checked the floating ground problem, but in vain. I have also tried different power supplies, but did not succeed.

3 - When I do not touch it, the PIC does not turn off, rather it gives a wrong output. This wrong output is a clock at some pins and any pulse with a different cycle on the others.

4 - I have directly and indirectly shorted the pin to earth, but of no use. Moreover, I connected a resistor equal to my body resistance and tried to pull the pin and up through it, but still it did not work.

At last, I want to clarify that it actually does work when I earth it through me. I have checked for a variety of outputs.

setar ansel 16f877

only a few reasons:

1) most likely: you have floating inputs (pins configured as inputs and not connected)
solution: all unused pins change to output

2) less likely: something wrong with crystal (replace)

3) even less likely: something really wrong with your pcb layout (crystal one meter away etc)

p.s. check if you init the pic portA as digital pins, by default they are ADC inputs!

for more details post an exact schematics plus pcb photo plus init code

pic 16f877a ansel

Your MCU's not running healtly.
ANSEL regs and configuration bits (set ANSELx = FF for Digital I/O)
OSC. circuit
check TRIS registers and set not used pins "0" form TRIS regs.Do not some free inputs ...

crystal for 16f887

I think this a ground problem you are acting as ground of the IC

16f887 porta

Get an 16F877A or 16F887. The 16F877 is a long outdated PIC and was replaced by the 16F877A. The new 16F887 is identical and has a few more features, like internal oscillator, and is 1/2 the price of the '877's.

Just a suggestion to get on the right track from the start.

porta problem pic 16f887

First check the hardware : power,reset,crystal
Second check software : difinition of Digital I/O (off ADC port),difinition output pin
Last check the solder pins

ic 16f877 photo

Try with a ~4MHZ crystal. If that works, check if you have configured the osc in HS mode.

Best regards,

pic16f877 earthing problem

I had exaclty the same problem with a Z80 loooong long time ago.
I even changed the Z80, used a lower frequency crystal, checked grounds, etc. Nothing.
I could even make it work slow motion, when i touched it, stop by releasing it, and then resume by touching it again.

The problem turned out to be the protoboard I was using. I changed it and everything worked perfectly. A friend of mine had the same problem but with a PCB board. He placed 100nF capacitors from VDD to VSS close to the ucontroller.
That worked for him.

Can't hurt trying.

Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to