16F877A inconsistant startup time

Status
Not open for further replies.

shsn

Junior Member level 3
Joined
Nov 28, 2012
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,523
Hi,

I'm having an issue with PIC16F877A where it starts up;
  • after significant amount of time, maybe 15 seconds, when it has been powered down for few minutes.
  • after about 0.5 seconds when powered off while it's running, then powering it on again quickly.

I tried with both PICkit 2 and regulated 5V and tried removing the load capacitors which are 33pF with 20MHz crystal.
What could be causing inconsistent start up time?

Thank you.
 

Upload your circuit diagram. It sounds like the problem is caused by capacitance either on the power line or MCLR.
 

Upload your circuit diagram. It sounds like the problem is caused by capacitance either on the power line or MCLR.

Thanks for prompt reply,

Here is my circuit diagram, all I do is connect the PICkit 2 header directly to the corresponding pins on 16F877A.
I've read that capacitors connected to the crystal oscillator determines the start up time but I don't think that is causing this.
Regardless I attached the screenshot.

Cheers.

View attachment test.BMP

And here's the code that I've used,
Code:
void main() {
     PORTC = 0;
     PORTD = 0;
     TRISC = 0;
     TRISD = 0;
     
     for(;;) {
             PORTC = 0x00;
             PORTD = 0x00;
             delay_ms(130);
             PORTC = 0xFF;
             PORTD = 0xFF;
             delay_ms(130);
     }
}
 

Are you simulating on Proteus? Did you try on hardware?

Connect MCLR to VDD through a 10k resistor. Use current limiting resistors in series with each LED. Use 330R.
 

Yes, I'm using Proteus. It works when simulating as expected but on hardware, as stated in the original post,
there's an unknown delay and inconsistent start up time before PIC starts executing the instructions.
I will follow your advice and make changes to the circuit.

Just out of curiosity, if MCLR is not connected to anything wouldn't it mean it's LOW or 0V?
Any particular reason for additional resistor for MCLR?

Cheers
 

Not connecting MCLR to VDD does not mean that it is low. It means that it is floating. Keeping an input pin floating is never a good idea.
 

It is necessary to connect 10k to the MCLR of you micro otherwise it keep working in random.
 

The behavior of the MCLR pin is usually defined by the configuration bits (which you haven't shown).

Keith
 

Tahmid,

Thanks, I didn't know specifically about that part number.

A useful tip for any PIC is to look for the 'minimum connections' diagram for the device (if there is one), usually in an early section of the datasheet. That will show which capacitors and resistors are required.

Keith
 

Thanks all for the suggestions, adding a 10K resistor worked perfectly.
The PIC powers on straight away now. Thank you
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…