I am trying to acquire a sine wave signal generated by the AD9833 using a PIC's onboard high-speed ADC. Instead of acquiring the signal in real-time, I am using downsampling to build up a single sine wave cycle out of multiple cycles. For example, if the sine wave signal is 1000Hz, and my ADC is operating at 999 Samples/s, then after 999 samples I should have exactly one cycle of the signal. In other words, since the f_sampling and f_signal are slightly off, every sample captures a point on the sine wave slightly offset in phase compared to the previous point.
Anyway, getting predictable results relies heavily on synchronization. If the relative sampling frequency isn't exactly 0.999*signal frequency, then after 999 points I'll be significantly off, in that the phase of the first point won't match the phase of the last point.
So the problem should be solved by sharing a clock source, right? If I clock the ADC timer using the same clock source as the one that feeds the AD9833, then they should always be perfectly synchronized, right? Even if there is error and/or temperature variation in the clock source, it shouldn't matter.
The problem is that I am seeing non-synchronization error, so that I cannot predict how much of the sine wave I will capture (can't predict the ending phase relative to the starting phase). Are my assumptions about a shared clock source wrong, or does the problem lie elsewhere?