
Originally Posted by
sougata
Hi,
If you use an 8 MHz crystal as your oscillator and let your timer0 run free it would interrupt @ 7.8Khz (Thanks to MisterE for the PIC multicalc utility). Enable timer0 interrupt. In the interrupt routine you don't need to reload timer0 as it already rolls over. This assures a solid timebase interrupting at fixed intervals. On the interrupt set the Go/Done bit of your ADC. Use the ADC in 8 bit mode. When the conversion is done. Simply dump the ADRESH value to the PWM duty register. All this happens in the interrupt routine. Let the AD module run continuosly so that sampling (acquisition) actually occurs when you are outside the interrupt. This should be quite simple to achieve. You get enough time outside the ISR to decide whether the ADC is sampling 0 or say 127 (when you are DC offsetting the Audio that gives you a 0 for the most negative peak, and 255 for most positive sort of pseudo signed ADC you loose resolution again, distort more).
Bookmarks