cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting stereo ADC to stereo DAC via DMA

flavio23
Associate III
Posted on June 20, 2016 at 14:39

I'm working on a preliminary feasibility study of a device based on the STM32F303RE platform.

The first step of this study is quite simple:

1. record a stereo stream from ADC peripheral

2. play the stereo stream using the DAC peripheral using a different sample rate

Obviously I'll use the DMA both to record and to play the data.

The problem is this: if I set the DMA for the ADC, the samples are recorded in an interleaved mode (even: samples from CH1, odd: samples from CH2). On the other hand, the two DACs need to be attached to two different DMA channels.

In other words: I cannot use the same array for both the ADC and the DACs, because the ADC creates an interleaved array (i.e., CH1(0), CH2(0), CH1(1), CH2(1). CH1(2), CH2(2), ...), but the DAC accepts only contiguous data (i.e., CH1(0), CH1(1), CH1(2), ...)

Is there an efficient way directly ''connect'' via DMA the data acquired by the ADC to the data the DACs will play?

The only alternative I know is to use one array for the ADC and two arrays (half sized) for the DAC, manually copying the data from the interleaved input array to the two output arrays. But this approach increases the SRAM requested memory, reduces the performance of the code and, more in general, eliminates all the benefits of using the DMA.

Thanks in advance!

#adc #stm32 #dac #dma
2 REPLIES 2
AvaTar
Lead
Posted on June 20, 2016 at 16:00

> Is there an efficient way directly ''connect'' via DMA the data acquired by the ADC to the data the DACs will play?

 

No - because (if I remember correctly) Peripheral-to-Peripheral DMA is generally not supported with STM32 MCUs.

And as such, it wouldn't make much sense, since such a feed-through would at most change the audio level, and add noise.

> The first step of this study is quite simple:  ...

 

This suggests further steps were you want to manipulate the data on the way from the ADC to the DAC. Thus, implementing a proper software interface for the data/buffer handling would not be lost time.

flavio23
Associate III
Posted on June 20, 2016 at 16:09

Thank you!

So I've got the solution: I'll start writing the middleware.

🙂

Thanks again