Maker Pro
Maker Pro

if there possible for pic to faulty?

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
If it works with the XT option, then you have not showed us the correct schematic. There is no crystal in your schematic. If you have no crystal, the oscillator should be set to the internal oscillator.

Bob
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
Wait a second, so XT option is for external osscillator right? Actually I doesn't use any external osscillator.
 
Last edited:

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
So, I doubt that your PIC is running. What makes you think it is?

Change the oscillator setting to INTOSC.

Edited:

Uh Oh, that is an ancient chip and has no internal oscillator. You must use either a crystal with the osc set to XT or HT, or use an external resistor and capacitor with the osc set to RC. See section 14.2 of the datasheet.

Where did you get that chip? There are much more capable chips at a fraction of the price of that chip available today.

Bob
 
Last edited:

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
I think this is reason why my led is not blinking.
#define __XTAL_FREQ 20000000
Above is instruction to declare speed of external oscillator.
So without put external oscillator the __delay_ms(); instruction not execute.
That I'm right guys? :confused:
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Without the external oscillator the PIC will just sit there dead and lifeless.

The clock is what breathes life into the chip. When the clock stops, the PIC stops.
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
Great explaination steve. That is my mistake not read a datasheet completely.
Now i realize PIC16F877A doesn't have internal oscillator.:eek:
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
Yup bob. Thank you to all because help me solve my problem.
Thumbs up to you'll.:D
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
Hi guys this problem is overcome.
I've make simple circuit to test my PIC.in this circuit switch as counter.
When counter=1 led1=on led2=off
When counter=2 led1=off led2=on
When counter=3 led1=on led2=on
When counter=4 led is off and counter back to 0.
When I try in simulation its working .
But, sadly when try in hardware its not working and nothing happen.I check the voltage its oky.power source that I used is battery 9V and lowered the voltage using by 78L05 voltage regulator. I allready pullup mclr pin and check the configuration bits.
FOSC=HS oscillator
WDT=disable
PWRTE=Enable
BOREN=disable
LVP=disable
CPD=off
WRT=off
CP=off

I attach this post with schematic circuit.
Hope u guys can help me solve my problem
 

Attachments

  • schematic2.jpg
    schematic2.jpg
    80.4 KB · Views: 134
  • LED2.txt
    1.2 KB · Views: 174

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
.1uF is way to big for the capacitors in the crystal oscillator. Try 27pF. Or better yet, look up the capacitance required for the crystal, then multiply by 2 since the two are in series, and subtract maybe 5pF for stray capacitance.

Bob
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
Uh..I tought can use any capacitor value. I'm missunderstood :D
TQ,bob.
 

gorgon

Jun 6, 2011
603
Joined
Jun 6, 2011
Messages
603
Normally 22 or 27pF can be used, and will work, but the exact value depends on your crystal's parameters.
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
I'm used 20mhz crystal oscillator, so which wan capacitor value is fit for my oscillator?
 

gorgon

Jun 6, 2011
603
Joined
Jun 6, 2011
Messages
603
If you are using an oscillator module and NOT a crystal, you don't need capacitors at all. The output of the oscillator is conected to the input of the PIC oscillator pins, or OSC1/CLKIN on Your drawing.

For us to say the capacitor value for a Crystal, we need to have the exact type description and brand name, but 22pF should be around the value.
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
If you are using an oscillator module and NOT a crystal, you don't need capacitors at all. The output of the oscillator is conected to the input of the PIC oscillator pins, or OSC1/CLKIN on Your drawing.

For us to say the capacitor value for a Crystal, we need to have the exact type description and brand name, but 22pF should be around the value.

Uh,thx gorgon.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
We'll stop laughing when you get it running! Did you try 22 or 27 pF capacitors yet?
15pF might also work for a crystal of that high frequency.

Bob
 
Top