# 16F877A inconsistant startup time

Status
Not open for further replies.

#### shsn

##### Junior Member level 3
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.

#### Tahmid

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

#### shsn

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

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);
}
}

#### Tahmid

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.

#### shsn

##### Junior Member level 3
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.

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

#### Tahmid

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.

#### kabeer02

##### Full Member level 5
It is necessary to connect 10k to the MCLR of you micro otherwise it keep working in random.

#### keith1200rs

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

Keith

#### Tahmid

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

Keith

True. But the PIC 16F877A does not allow the disabling of MCLR for use as IO pin.

#### keith1200rs

##### Super Moderator
Staff member
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

#### shsn

##### Junior Member level 3
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.