2019-09-25 08:06 AM
Hi,
I'm using STM32F207 and I'm trying to make three different ADC measurements on three difeerent ADC.
My purpose is to make 100.000 measurements on each of these signals at the highest speed possible.
With only one signal (so using only one ADC) I can make 100.000 measurements in 3,88 secondes but withg three different signals I need 11,69 seconds to make all these measurements (3 * 100.000 measurements)
Here my code
for (uint32_t i = 0; i<100000; i++)
{
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1, 100);
adcResult_many_ADC1[i] = HAL_ADC_GetValue(&hadc1);
HAL_ADC_Stop(&hadc1);
HAL_ADC_Start(&hadc2);
HAL_ADC_PollForConversion(&hadc2, 100);
adcResult_many_ADC2[i] = HAL_ADC_GetValue(&hadc2);
HAL_ADC_Stop(&hadc2);
HAL_ADC_Start(&hadc3);
HAL_ADC_PollForConversion(&hadc3, 100);
adcResult_many_ADC3[i] = HAL_ADC_GetValue(&hadc3);
HAL_ADC_Stop(&hadc3);
}
Is there a way to decrease this time by coding it differently ?
Thank you for your help :smiling_face_with_smiling_eyes:
Solved! Go to Solution.
2019-09-25 08:41 AM
>>Is there a way to decrease this time by coding it differently ?
The prescribed mechanism is to use DMA, and put the ADC into a continuous mode, this will be massively more efficient than this kind of polling nonsense.
Triple Simultaneous mode world even provide the measurements on the three channels at the same instant, and not displaced across the time domain.
Ceiling there is around 2 MSps, interleaving offers 6 MSps, but that basically reads the same channel but with staggered starting points across the 3 ADC
2019-09-25 08:16 AM
Use injected channels, ask each ADC to continuously convert over and over the channel you selected.
Do this to all 3 ADC
Launch all 3.
Read each ADC register whenever you want, the register is updated asap. In the end you might just poll for a conversion complete flag, no wait, no delay.
Above code is sequential so the loop slows with ADC and channels to convert.
Don't know exactly which HAL function to use, check the header files related to HAL_ADC
2019-09-25 08:24 AM
Thank you a lot for your answer.
I am not familiar with this but I'm going to dig into it
2019-09-25 08:41 AM
>>Is there a way to decrease this time by coding it differently ?
The prescribed mechanism is to use DMA, and put the ADC into a continuous mode, this will be massively more efficient than this kind of polling nonsense.
Triple Simultaneous mode world even provide the measurements on the three channels at the same instant, and not displaced across the time domain.
Ceiling there is around 2 MSps, interleaving offers 6 MSps, but that basically reads the same channel but with staggered starting points across the 3 ADC
2019-10-02 08:14 AM
Hi,
Thank you @Community member I tried you idea (it took me some time to understand how all this works) but now with a single ADC I have a sampling frequency of 144kHz for each one of my three signals which is much better than before.
Thanks a lot for your help.