Hey guys,
I'm starting to play around with the ADC functionality and was wondering: How would one configure the ADC for a specific sample rate (i.e. xxx samples per second)?
I noticed that the adc.h header file defines an adc_smp_rate
enum which features sample rates in a # of ADC cycles per sample, but that seems rather fast. I also understand (I hope) the ADC clock is running at 12MHz (72MHz / 6 divider). At the very slowest sample rate of 239.5 ADC clocks per sample that's 20uS per sample, or 50kHz. That's great, but what if I want a 8000Hz sample rate, or 44.1kHz sample rate?
I've gotten ADC samples to be stored in SRAM via the DMA1 Channel 1 controller, but it's going too fast (I know, right?). Very primitive benchmarks [1] suggest a ~550kHz sample rate with ADC_SMPR_7_5, though I know my benchmark is VERY bad (polling the ISR bit !== smart) but the DMA interrupt stuff isn't working right just yet.
Would I be best off setting up a timer with a xxxHz interrupt and sample the ADC manually rather than using the ADC's DMA? It's probably meant for people who need high sample rates.
Cheers,
-robodude666
[1] https://gist.github.com/1019639 - My primitive ADC + DMA testing/benchmarking. There, it's on gist and not inline =].