If you do not have a high precision frequency counter, you can still adjust the crystal quite accurately if you have another time base that is very accurate and a decent oscilloscope. Connect the output of the precision frequency source (such as a can type 4.000000 MHz oscillator) and the OUTPUT of the PIC oscillator to a pair of series connected 100k resistors. Connect ground to the scope ground, and connect the scope probe to the junction of the two resistors. Trim the PIC XTAL until the observed waveform "settles down". At that point both oscillators are at the same frequency or locked to a multiple or submultiple of one another. 100k 100k PIC OSC OUT >------/\/\/\---*---/\/\/\-------< REFERENCE FREQ. | +---------> TO SCOPE Fr. Tom McGahee -----Original Message----- From: Don Hyde To: PICLIST@MITVMA.MIT.EDU Date: Thursday, March 09, 2000 11:26 AM Subject: Re: Why doesn't 1+1=2? 1 second in 10 minutes = 1 second in 600 = .16% error, better than is to be expected from a .5% precision timebase. So your code is probably just fine. If you want more accurate timing, you're going to have to start with a more accurate timebase, such as a 20ppm crystal which should give more like .012 second error in 10 minutes. Now, you must also understand that to get the 20ppm from your crystal, you will have to, at least once, fiddle with the crystal loading caps and a high-quality counter to adjust for the stray capacitance on your board. Once you have found the right cap values, they will be pretty consistent for a production run, but you still may need a tweaker on the crystal to get it right on.