ADC sampling rate

Discussion specific to the 24-pin ZX microcontrollers, e.g. ZX-24r, ZX-24s and ZX-24t.
Post Reply
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

ADC sampling rate

Post 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?
Tom
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: ADC sampling rate

Post 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.
- Don Kinzer
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

ADC sampling rate

Post by GTBecker »

> ... Seven RTC ticks would yield a frequency of approximately 3.6KHz...

I don't follow. Isn't the RTC tick 512Hz?
Tom
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: ADC sampling rate

Post 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.
- Don Kinzer
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

ADC via DMA

Post 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?
Tom
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: ADC via DMA

Post 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.
- Don Kinzer
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post 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.
Tom
Post Reply