Page 1 of 1
ADC sampling rate
Posted: 06 July 2014, 9:59 AM
by GTBecker
I want to, in essence, record a few hundred mS of audio (actually an analog accelerometer) at 3.6kHz then play it back.
Currently I can achieve a 7.2kHz rate by setting the ADC prescaler register value to 7 (the largest, slowest, value available on a ZX-24u) which yields 7200 samples per second from the ADC hardware; that's slow enough that code can spin and wait for each completion, and read and store the result without missing a sample. To get 3.6kHz, I can deliberately ignore alternate samples, or average two.
Is there another method to achieve 3.6kHz-clocked ADC sampling?
Re: ADC sampling rate
Posted: 06 July 2014, 11:06 AM
by dkinzer
GTBecker wrote:Is there another method to achieve 3.6kHz-clocked ADC sampling?
An ADC conversion can be triggered by the event system. It may be possible to configure an event to fire at the rate you want.
It may be simpler, however, to use WaitForInterval() in a separate task to read the previous conversion result and start a new conversion. Seven RTC ticks would yield a frequency of approximately 3.6KHz.
ADC sampling rate
Posted: 06 July 2014, 14:13 PM
by GTBecker
> ... Seven RTC ticks would yield a frequency of approximately 3.6KHz...
I don't follow. Isn't the RTC tick 512Hz?
Re: ADC sampling rate
Posted: 06 July 2014, 15:36 PM
by dkinzer
GTBecker wrote:Isn't the RTC tick 512Hz?
You're right, of course. Sorry for the confusion.
You could set up a timer to generate an interrupt at a 3.6KHz rate and use the ISR to collect a sample and start the next conversion.
ADC via DMA
Posted: 07 July 2014, 18:01 PM
by GTBecker
Pushing the envelope, I'd like to explore high-speed ADC sampling using DMA to store results directly into a named var on a ZX-24u (ATxmega128a4U). A site search shows no DMA references.
Has anyone tried?
Re: ADC via DMA
Posted: 07 July 2014, 18:53 PM
by dkinzer
GTBecker wrote:Has anyone tried?
I haven't explored using DMA and I don't recall seeing any posts on the topic. A Google search using the terms xmega and DMA turned up several promising hits including an Atmel application note and an AVR Freaks thread that is exactly on point - capturing audio via the ADC and storing the samples in RAM using DMA.
Posted: 07 July 2014, 19:07 PM
by GTBecker
I'd just printed the Atmel ADC and DMA app notes and the avrfreaks thread (
http://www.avrfreaks.net/index.php?name ... 00&start=0), very promising, when you posted. Thanks.