cancel
Showing results for 
Search instead for 
Did you mean: 

Dual regular simultaneous mode ADC triggered from timer 4 using DMA1

AndreaC1985
Associate II
Posted on June 26, 2018 at 14:32

Hello all,

I have cube 4.25.1 installed and I'm using stm32f303 mcu.

What I have to do is to read 5 analog channels with ADC1 and 5 analog channel with ADC2 triggered from timer 4 counting.

I read application note An3116 and it said that it is possible to trigger simultaneus reading of sequence of channel.

0690X0000060LOWQA2.png

I used the cube configuration attached:

than after the hardware inizialization is performed the instruction below:

HAL_ADC_Start(&hadc2);

HAL_ADCEx_MultiModeStart_DMA(&hadc1, (uint32_t*)adc_array, sizeof(adc_array));

where adc_array is 32 bit array is a 5 item array.

Is there some error in the configuration or in the ADC start command?

Is there some software example using the new stm32 hal library?

Thanks

6 REPLIES 6
T J
Lead
Posted on June 26, 2018 at 15:51

I am only using a single channel, but this is my init code

typedef enum {

    Rs8_Ad1,

    Rs5_Ad5,

    Rs1_Ad6,

    Rs2_Ad7,

    Rs3_Ad8,

    Rs4_Ad9,

    CurrentSense_Ad13,

    Rs6_Ad14,

    Rs7_Ad15,

    VTemp_Ad16,

    VRef_Ad17,

    VBat_Ad18,

    ADC_ChannelCount,   // channels count

} ADCresultsAveColumn_t;

    HAL_ADC_Start_DMA(&hadc, (uint32_t *)ADC_DMABuffer, ADC_ChannelCount);
Posted on June 26, 2018 at 15:59

Your ADC DMA is set to transfer Words at 32bit, my code the DMA transfers Half-Words.

I never used that processor sorry,

but under ADC properties, ranking, with sampling at 1.5 cycles,

that's as fast as it goes, it will be unstable and drifting around and incorrect.

Posted on June 26, 2018 at 16:30

Hello TJ,

when

multimode.Mode = ADC_DUALMODE_REGSIMULT;

I checked the post below and in order to start the conversion uses my same functions:

https://community.st.com/0D50X00009XkY98SAF

For the sampling time I can try to increase and Let you know the result.

Regards

Posted on June 26, 2018 at 16:59

I tried increasing the sample time but it doesn't seem to be the problem.

Do you know if there is some adc software example where task are performed using the new HAL library 

cubemx 4.25.1 or later?

I found some example but they all uses old HAL library.

AndreaC1985
Associate II
Posted on June 28, 2018 at 10:07

somebody has some hints related to this problem?

Posted on June 29, 2018 at 01:46

Hi, sorry to be a bit busy...

Did you notice in your ICO file that the ADC config DMA is moving 32 bits ?

it is supposed to be 16 bits...

Are you seeing any data ?