cancel
Showing results for 
Search instead for 
Did you mean: 

Which DMA-Channels for simple Audio (Mono ADC/DAC)?

flyer31
Senior
Posted on February 27, 2016 at 12:58

Hi,

could somebody recommend me perhaps, which DMA configuration to use for simple Audio (STM32L4, Analog micro connected to ADC, simple speaker amp connected to DAC - I want do record to WAV files and play back from WAV files on some SD card).

(I do NOT want to use a digital interface as SAI, I2S ... I need to accomplish the audio things with as few pins as possible, and I hope that for ADC/DAC I need only 1 line for the micro ADC and 1 line for the speaker DAC).

I am still planning the PCB layout configuration, not yet inside the software:

For the Micro side: Is it better to use a DMA channel of an ADC, or is it better to use some Timer DMA channel (which would be much more flexible of course, as there are very many Timer DMA channels).

For the Speaker side: Is it better to use a DMA cannel of an DAC, or is ok to use some Timer DMA channel?

I hope that maybe I can use the same timer, e.g. TIM17, and then configure two DMA channels for this timer (e. g. Channel 1 and 7), and then perform recording and playing with one timer (only if recording + playing should be necessary, but usually anyway I would either record or play...).

#audio-adc-dac-dma-stm32l4
2 REPLIES 2
mark239955_stm1
Associate II
Posted on February 28, 2016 at 10:40

I can’t speak in detail for the L4 parts, because I haven’t used the part yet, but I may be able to help by drawing on my experience with the F4 parts.

 

I’ve sniffed around a little in the L476’s reference manual and confirmed that they’re very similar.

The way ST have designed this to work is:

  1. A timer triggers an ADC or DAC conversion.
  2. When the conversion completes the ADC or DAC triggers a DMA transaction.
  3. When the required number of conversions have occurred, the respective DMA complete interrupt fires.

You can use TIM6 to generate triggers for either an ADC or DAC.

 

It generates a trigger on update events, e.g. in upcounting mode when it wraps from the value in ARR to 0.

 

You can also use other timers, but exactly which ones are options depends on whether you’re working with the ADC or DAC.

 

Personally I’d probably use two different timers or timer triggers sources (e.g. some timer output compare triggers can be used for the ADC) and stagger them so that the ADC and DAC conversions are 180 degrees out of phase.

Looking at the L476 reference manual, there are a number of options for the DMA.

 

The obvious choice is DMA1/Channel1/Request0 for the ADC and DMA1/Channel3/Request6 for the DAC.

 

If you have no particular constraints on your DMA, e.g. conflicts with other hardware like SD/MMC or SPI for your SD card, then there’s really no reason that I’m aware of to use any other configuration.

Obviously there’s a fair bit of work involved in understanding how the hardware works and then getting it set up to operate the way that you require.

 

I strongly recommend not using Cube’s HAL and just accessing the peripheral registers yourself.
flyer31
Senior
Posted on February 28, 2016 at 13:00

Thank you very much for your very helpful and complete answer!