cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F1 - ADC in DUAL mode

matic
Associate III
Posted on July 24, 2015 at 22:27

Hi. Let me describe the situation. 

I have to do 8 AD conversions (using STM32F103) as fast as possible. Thus, I'd like to use ADC in DUAL mode to execute 4x2 conversions (on ADC1 as master and ADC2 as slave) and transfer them with DMA. As far as I know I should use dual regular simultaneous ADC mode for this task. And probably also SCAN mode for executing all 4 pairs of conversion one after another. I don't want to use CONTINUOUS mode, because I'd like to start conversions when I want.

I have a problem with configuration of a DMA and ADC modules. I was searching a lot on the web, but everything that I found was written with STD Libraries. I am quite new on STM32 MCUs and have some experience only with newer HAL Drivers.

Now, my question is, if anyone has such case made with HAL Drivers? Or if anyone has some kind of advice?

Things that I'm the most interesting in are how to configure DataWidth for DMA Peripheral and Memory side (halfword, word). Any kind of advice would be very helpful and appreciated.

#adc #adc_dual #dma #hal-driver #stm32f1
4 REPLIES 4
Amel NASRI
ST Employee
Posted on July 27, 2015 at 14:40

Hi obid.matic,

You can start from CubeMX generated code: you configure the peripherals to be used the way you want, then you generate your project. After that, you have to add the calls for processing functions as well as the callbacks.

The examples provided within the STM32Cube Package can be taken as reference to be updated depending on your needs (Ex:  STM32Cube_FW_F1\Projects\STM3210C_EVAL\Examples\ADC\ADC_DualModeInterleaved).

The DMA configuration doesn't depend on the usage of SPL or Cube. You have just to understand the parameters required for DMA.  If not yet done, I advise you to read carefully the DMA chapter in RM0008.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

matic
Associate III
Posted on August 11, 2015 at 07:26

Hi Mayla.

Thank you for your response. Now, that works for me. I make 8 AD conversions in DUAL mode (4 x 2 conv.). I get these values in 32-bit array with 4 elements and then separate them to 8 16-bit values. But this takes some time. Now, I have a further question:

Is it possible to configure DUAL mode in the way, that I will get already separated values in my destination array? Thus, I should define an array with 8 16-bit elements instead of 4 32-bits.

Thanks
ardavantycoon
Associate II
Posted on February 24, 2016 at 16:50

How you do that? Plz put your code here. 

I use this procedure but unsuccessful.

     *** Multi mode ADCs Regular channels configuration ***

     ======================================================

     [..]        

       (+) Select the Multi mode ADC regular channels features (dual or triple mode)  

          and configure the DMA mode using HAL_ADCEx_MultiModeConfigChannel() functions. 

       (+) Start the ADC peripheral using HAL_ADCEx_MultiModeStart_DMA(), at this stage the user specify the length 

           of data to be transferred at each end of conversion           

       (+) Read the ADCs converted values using the HAL_ADCEx_MultiModeGetValue() function.

kl4971tse
Associate II
Posted on November 25, 2016 at 23:08

Hello,

You would need to use HAL_ADC_Start() on all the slave ADCs prior to using HAL_ADCEx_Start_DMA on the master.