AnsweredAssumed Answered

Triggering ADC in Dual Mode with DMA - problems

Question asked by shlapunov.nicolai on Dec 21, 2016
Latest reply on Jan 13, 2017 by Jeanne Joly

Hi,

 

I(or may be ST) have a ptoblem. I tried to use ADC1 & ADC2 in regular dual mode with DMA on STM32F103C8T6 MCU(startup code generated by last CubeMX). If I configure ADCs in continues mode, then start ADC2(using HAL_ADC_Start()) and then start ADC1(using HAL_ADCEx_MultiModeStart_DMA()) all works fine. But it is too fast collect data.

I remove continues bit from ADCs in my code:

MODIFY_REG(hadc2.Instance->CR2, ADC_CR2_CONT, ADC_CR2_CONTINUOUS(DISABLE));
MODIFY_REG(hadc1.Instance->CR2, ADC_CR2_CONT, ADC_CR2_CONTINUOUS(DISABLE));

and start them again. In timer interrupt I trigger ADC1:

SET_BIT(hadc1.Instance->CR2, (ADC_CR2_SWSTART | ADC_CR2_EXTTRIG));

And happens something strange: all looks fine, DMA collect data but data from ADC2 is invalid. Looks like it same data as in first conversion after start ADCs. I found, that if I will set ADC_CR2_EXTTRIG flag for ADC2 before triggering ADC1 all works fine:

SET_BIT(hadc2.Instance->CR2, ADC_CR2_EXTTRIG);

SET_BIT(hadc1.Instance->CR2, (ADC_CR2_SWSTART | ADC_CR2_EXTTRIG));

But it very strange, because in debugger CR2 register for ADC2 already has ADC_CR2_EXTTRIG flag before this two strings and register does not change when I run thru this strings.

 

It is looks fine - just one more string in code... but real problem happens when you try triggering ADC1 using external trigger or timer trigger output. ADC2 just not work. And you cannot fix it - you cannot write register for ADC2 after each conversion... or I missed something?

 

Thanks,

Nicolai

Outcomes