Crystal Oscillators – As Easy As It Seems
I just wanted a quick post for people like me who think that some things can’t be as easy as they seem. In this case, using a crystal oscillator.
Looking in the data sheet for your PIC, it will show you the different ways the PIC’s clock can be driven. You’ll notice that in terms of hardware, the only thing you have to do is hook the two sides of your oscillator to the two designated oscillator pins on the PIC and then hook those same two pins to ground in series with very small capacitors. The optimal values of the capacitors is found in the data sheets of either the PIC or the crystal. That is it for hardware. For software, it is just as easy. Once again, using the data sheet as a reference, you set up the configuration word according to the crystal speed and type you have.
Once the PIC is powered, you can use an oscilloscope to check the oscillator pin. It will not be a square wave, just a very steady sine wave. However, without power, the oscillator won’t be doing anything.
And that’s it. “Wait,” you may say, “that’s really it? All that information is in the data sheets.” And that was the point. There is absolutely nothing tricky about the crystal oscillator and no reason you shouldn’t be able to use one in your projects.
Comments
Comment from Joshua
Time October 14, 2010 at 1:18 am
I’ve found that’s actually one of the difficult things for me to tell in the datasheet is that which would be nice for stability and rugged hardware and what is necessary for the thing to actually function at all. I think that for this, it would nice to give a solid and common reference point, but if it works, it works, I don’t think you’re hurting anything. However, my recommendation would be to follow the datasheet and add the capacitors, if and when you’re able.
Comment from h2ile
Time October 13, 2010 at 5:23 am
I don’t connect the 2 pins (osc1 and osc2) to ground, using the crystal only. It works, but is it bad?