I'm using the ADC of PIC18F452 to read a sound signal of freq around 70 Hz. My goal is to take the readings with a rate of at least 10 times and store them on an SD card for later use of data. I'm using a 20MHz OSC.
My problem is that I need to get the readings with a uniform (and known) sampling to be able to process the data later. I thought of using a timer and interrupt but that will make the readings slow.. any idea how to do that (know the exact timing between readings and insure it's at least 700Hz) ??
If you look into the datasheet Chapter 17.5 Use of the CCP2 Trigger (at least in my copy) , you see that you can let the Timer trigger the conversion directly without invoking an interrupt. That would ensure a stable timing (as stable as your Oscillator permits) and save the overhead of calling the interrupt. Since the processor has no DMA you still have to copy the AD conversion results after the conversion finished.
I'm not sure I understand exactly what you mean. do you mean I should let CCP2 trigger the ADC every known time period? and wouldn't saving the results before starting a new conversion affect the uniformity of time??
Yes, that was the idea. The timer in CCP2 can provide the timing for equally spaced samples. Since the sampling itself is triggered by the timer you don't have delays coming from the software (for triggering). After the value is sampled you have to copy it to another location though. That has to happen before the next conversion...
Why should the copying of the value affect the uniformity of time? If the ADC samples at times e.g. 0ms, 14.2ms, 18.4ms it does not matter when you copy the values inbetween these timeslots. The values are sampled and won't change till the next sampling is triggered.