# Crystal oscilator not oscilating on a PIC

I am experimenting with a PIC16F84A at the moment.

I can get this working fine using an RC network for the clock.

When I switch to using a crystal (the usual xtal across pins 15&16 with 2 caps going to ground from the same pins) I am not getting any clock at all.

The PIC is the 20MHz version, and I have tried all the crystals I have - 4MHz, 14.3MHz and 25MHz, and numerous different capacitors rangeing from 22pf right up into the uF range, but all I get is what appears to be a logic high on pin 15 and a logic low on pin 16.

Yes, I have changed the program config to be _XT_OSC (I have tried them all), but to no avail.

I am using gpasm to assemble the program and pk2cmd to flash the PIC in circuit under Ubuntu.

Any clues?

Edit: diagram:

            22pf
16 o----+---||----+
|         |
-         |
|=|Xtal    +---+
-         |   |
|         |   _
15 o----+---||----+   - GND
22pf


(a little crude, I know ;) )

• 22pF may be even too high. Try 12-18pf range. Also, are you using a breadbord? – Hans May 14 '11 at 15:34
• Ohkay - if I run it in HS oscillator mode, and ditch the capacitors (just have a crystal linked between pins 15 and 16) I get it working. If I then add the capacitors it stalls. Well, I say stalls - it appears to possibly be working at about 0.1Hz. – Majenko May 14 '11 at 16:27
• Solderless breadboards can be troublesome, especially for circuits involving crystal oscillators; I never use them. Try putting it on a PCB. – Leon Heller May 14 '11 at 16:48
• Do not stay too long with the 16F84. It is obsolete, expensive, limited in capability. Try 16F88 instead: finitesite.com/d3jsys/16F88.html – markrages May 14 '11 at 16:55
• @MattJenkins, it is actually the input capacitance and inductance of the scope probe that often kills the xtal when you touch it. Second, as pointed out, too much capacitance can often be a larger issue then too little. – Kortuk May 15 '11 at 6:41

You might have too much capacitance on the oscillator pins this can be caused by:

1. Using the wrong capacitors for the selected oscillator/crystal.
2. Building your circuit on a breadboard which increases capacitance in the circuit.
3. Connecting a scope probe to the oscillator circuit.

When measuring the oscillator frequency it is best to connect the probe to the oscillator through a buffer. The PIC microprocessors often have a CLKOUT pin that serves this function, but it can only be used in some oscillator modes.