4
\$\begingroup\$

I am using PIC micro controller (PIC16F1846) with an external 8MHz crystal attached to the external clock pins (RA6 and RA7).

Why is it that when I use my oscilloscope probe to attempt to measure the clock frequency my basic LED flashing program stops working (light state freezes) and I have to perform a reset?

\$\endgroup\$
  • \$\begingroup\$ Do you connect your oscilloscope to RA6 and RA7 at the same time ? I mean, probe tip to one and ground to the other ? Do you use a proper 1:10 probe ? \$\endgroup\$ – Bimpelrekkie Sep 29 '15 at 13:49
9
\$\begingroup\$

Try a 10x (not 1x) probe on the OSC2 pin. You should be able to see the clock. The frequency will be slightly changed by the probe loading.

I don't think your part number is correct, but most 16F chips are similar.

Edit: Scope probe loading is explained in this Tektronix paper.

Crystal pullability is explained in this application note. Note that the typical loading from a 10x scope probe would only change the frequency by perhaps 100ppm (0.01%), which is unimportant in many applications other than timekeeping.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Your correct, the part is actually PIC16F1847. Using the probe in x10 worked! \$\endgroup\$ – user3095420 Sep 29 '15 at 13:54
  • \$\begingroup\$ Could you explain this idea of the probe loading affecting the frequency? \$\endgroup\$ – user3095420 Sep 29 '15 at 13:54
  • \$\begingroup\$ Please see edit above \$\endgroup\$ – Spehro Pefhany Sep 29 '15 at 14:10
  • \$\begingroup\$ pdf link isn't working for me. \$\endgroup\$ – Dan Is Fiddling By Firelight Sep 29 '15 at 17:26
  • \$\begingroup\$ @DanNeely Should be working now. Tek appended some stuff to the URL that maybe was intended to discourage deep linking. \$\endgroup\$ – Spehro Pefhany Sep 29 '15 at 20:13
9
\$\begingroup\$

This is a separate but related topic.

Measuring the frequency at the oscillator out pin tells you the oscillator frequency, not necessarily the instruction clock frequency. On old PICs, that was just 1/4 of the oscillator frequency. However, many newer PICs have more complicated clock chains than that, with a PLL and various optional dividers.

It is a good idea to make sure the instruction clock is actually what you think it is as early as possible. I usually do this by having my main loop initially just toggle a pin. Set up the bank for the appropriate LAT register first, then BSF, BCF, and BRA back to do it again. That should take 4 instruction cycles. You look at that on a scope and verify the pin frequency is really 1/4 of the instruction clock that you expected.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Although this doesn't directly answer my question it is a very good point and probably has saved me a lot of pain down the line. Thank you! \$\endgroup\$ – user3095420 Sep 29 '15 at 14:48
1
\$\begingroup\$

Capacity of the probe could cause failure of the clock generation. The simpliest way to prevent this is to wire a resistor to the central contact of the probe and perform the measurement placing another leg of the resistor onto your crystal. 100 Ohms will be fine.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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