4
\$\begingroup\$

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

\$\endgroup\$
19
  • 2
    \$\begingroup\$ 22pF may be even too high. Try 12-18pf range. Also, are you using a breadbord? \$\endgroup\$
    – Hans
    Commented May 14, 2011 at 15:34
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – Majenko
    Commented May 14, 2011 at 16:27
  • 1
    \$\begingroup\$ Solderless breadboards can be troublesome, especially for circuits involving crystal oscillators; I never use them. Try putting it on a PCB. \$\endgroup\$ Commented May 14, 2011 at 16:48
  • 3
    \$\begingroup\$ Do not stay too long with the 16F84. It is obsolete, expensive, limited in capability. Try 16F88 instead: finitesite.com/d3jsys/16F88.html \$\endgroup\$
    – markrages
    Commented May 14, 2011 at 16:55
  • 2
    \$\begingroup\$ @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. \$\endgroup\$
    – Kortuk
    Commented May 15, 2011 at 6:41

3 Answers 3

3
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

Add a 1Meg Ohm resistor in parallel with your xtal

\$\endgroup\$
3
  • 1
    \$\begingroup\$ can you elaborate on your answer? \$\endgroup\$
    – jsolarski
    Commented Jun 15, 2011 at 12:14
  • 1
    \$\begingroup\$ I think what he's thinking of is a bias resistor to keep the CMOS inverter near its threshold region. This is necessary when using a CMOS inverter as the gain element in a crystal oscillator. PICs already have this built in. I've done over 100 PIC projects and never needed to add a external bias resistor. However, I have seen Microchip mention it on occasion. I don't think this was a dumb suggestion deserving a downvote, so I'm upvoting it to cancel that out. \$\endgroup\$ Commented Jun 25, 2011 at 12:42
  • \$\begingroup\$ @Olin - I guess it was downvoted for lacking detail, not for being wrong. \$\endgroup\$
    – stevenvh
    Commented Jun 25, 2011 at 13:30
-2
\$\begingroup\$

I've always been able to solve this problem by reducing, or often totally eliminating the capacitors. I've had this problem more times than I care to count, but it's never failed to fix the problem.

\$\endgroup\$
2
  • \$\begingroup\$ Hm, I don't know if I can recommend this. My experience is that on most oscillators this has an adverse effect. \$\endgroup\$
    – stevenvh
    Commented Jun 25, 2011 at 12:27
  • \$\begingroup\$ I agree with stevenvh. Without any caps it could start oscillating at overtone frequencies. Also, without the right load on the crystal, the frequency will likely be a little out of spec, even if it oscillates at the fundamental. \$\endgroup\$ Commented Jun 25, 2011 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.