I'm using a dsPIC33F (Microchip) to sample a 555-timer signal. I've tried square, triangular, and "sinusoidal" signal shapes, but always have the same problem: the ADC samples the waveform correctly, but the result is always half of the expected frequency.

For example, my input is 440Hz, and when I plot what the ADC writes to the buffer, I get: Without the lines it is: On the oscilloscope I read it as 440Hz. My sampling frequency is 8kHz (which I checked with the oscilloscope by toggling a pin), and as I change it, the sampled values change to reflect that, so I'm almost certain I'm using the correct timer to trigger the ADC. Since each point represents 1/8000 = 0.000125s, the above graphs show a waveform with a period of 36*.000125=0.0045, or 222Hz.

I feel like the conversion time should have no effect, as long as it's shorter than 0.000125s. I'm confident that it is, and have tried different conversion times with no change. I know it's not the most efficient way of doing things, but to start I also convert only one sample at a time before triggering an interrupt and writing to the buffer. I'm not sure if that would matter.

If anyone has any ideas, I'd be grateful.

• When you checked the sampling frequency by toggling a pin, did you toggle the pin at the sampling rate, and measure the output waveform frequency as 8kHz? That would mean that the sampling clock is 16kHz. Jul 9, 2015 at 19:02
• Wow, I figured it would be a dumb mistake, but I had hoped something a bit more respectable than that. Thank you. I wish I'd asked sooner. Jul 9, 2015 at 19:15
• Glad you got it sorted out. I converted my comment to an answer so the question can be marked as resolved. Jul 9, 2015 at 19:19