AnsweredAssumed Answered

Continuous MultiChannell DMA scan through HAL/ cube

Question asked by new guy on Sep 18, 2015
Latest reply on Sep 20, 2015 by new guy

I would be grateful for some advice...

I know how to make a single ADC do a continuous DMA round-robin conversion of a sequence of different channels, using the pre-Cube version of FW.

 Having enables scan mode, you just list them like this...
  ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 1, ADC_SampleTime_41Cycles5);

  ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 2, ADC_SampleTime_239Cycles5);

 ...etc 

However, even after reading the STM32F4 HAL manual UM1725, I can't figure out the syntax for feeding in the sequence of channels, setting priorities etc, to do the above through the modern cube/HAL. 

I would be grateful if some kind soul could provide a known correct example!

I was thinking maybe you just repeat the following over and over, but it can't be right because there is nothing to say which ADC the channel specifications belong to.


   sConfig.Channel = ADC_Channel_11;       //???? but for which adc
  sConfig.Rank = 1;                                       // ??? does this mean position in sequence?
  sConfig.SamplingTime = ADC_SAMPLETIME_56CYCLES;
  sConfig.Offset = 0;                                  // Whats this for?

 sConfig.Channel = ADC_Channel_17;
  sConfig.Rank = 2;
  sConfig.SamplingTime = ADC_SAMPLETIME_56CYCLES;
  sConfig.Offset = 0;

It occurs to me that under HAL, its the ADC handle that refers to the ADC peripheral.
So if you do your adc1 handle init, then do the above, then do the adc2 handle init, and then repeat code above again - does that somehow make the sconfig code (exact same syntax/values) refer to different channels on different adcs? Surely not- surely you have two distinct "instances" of AdcHandle, one called ADC1 and another called ADC2? Then again, this is not C++, maybe the instance is overwritten so that subsequent sConfigs apply to a different ADC? I don't know...

Does rank means position in scan sequence?
What does sconfig offset mean?

  Thanks!

Outcomes