View Full Version : How do I check my crystal's operation/configuration?
flotulopex
- 21st July 2024, 19:42
Hi All,
I'm starting a project where a 20MHz crystal is needed. But my circuit refused to work above 10MHz for hours.
Finally, I found the catch: I mistaken the config settings; instead of _HS_OSC I had _XT_OSC and I couldn't see it... :o
Now, I was wondering if there is a "simple" way to check the good operation of the crystal and how to adjust the load capacitors and serial resistor.
I have found some DS and AN from MicroChip about oscillators but before I go for a sleepless night trying to understand them, I'm just asking for a "quick" check method, if there is any.
Is there one?
Ioannis
- 21st July 2024, 20:42
Probing directly on the OSC pins may lead to a non working oscillator, due to loading of the circuit by the probe.
You may check the proper operation with an oscilloscope on a pin for the right frequency of 1 or 10 Hz.
Even if you do not have an Oscilloscope, you can approximately see a LED flashing, for example at a 1Hz rate.
Ioannis
Demon
- 21st July 2024, 21:21
I usually put a heartbeat LED on a PIC before I start doing intense coding; just to make sure my CONFIG is set up right.
500mSec ON
500mSec OFF
That way it's relatively closer when you count along with it.
flotulopex
- 22nd July 2024, 13:37
Thanks,
I actually meant to verify the chosen capacitors and resistor and so on.
Guess I have to go back there: https://ww1.microchip.com/downloads/en/appnotes/00949a.pdf
amgen
- 22nd July 2024, 22:54
I have been using 20MHZ xtal's on 18f's..... just straight crystal no r or c's. I make 10 hz interrupts and main program loops on that, toggle blinks a heart-beat led at 10x/sec and no pauses in in code, just use counts of 100ms to do 'tasks'. so to check the timing, I did a serout of simple counter (using longs) once each 10 loops which is 1 serout per second. Then when I start up the pic along with a clock on my pc, and check after 1 or 2 or 5 or 60 minutes, the seconds should sync with time elapsed in seconds, for example after 60 minutes count should be 3600. I found it amazingly accurate using timer 1 and preload. Then all the programming and work is done in the loops or in other interrupts. I also get a % reading of the pic's usage or idle amount using the main loop.
9691
flotulopex
- 23rd July 2024, 16:40
Thanks amgen, good idea :wink:
That's the kind of thing I was looking for.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.