I get an ADC overrun with multimode, scan and timer-triggered configuration
- October 5, 2020
- 4 replies
- 2993 views
I'm using the STM32F446VE with 3 ADCs. I have a 50 kHz PWM running and want 2 of the ADCs to measure 2 Channels synchronized with the 50 kHz PWM.
To achive this I used the regular simultanuous dual mode, and triggered the master ADC with the Trigger 8 Timer Out event, which runs at 50 kHz (by now I assume this doesn't make sense, as I could just trigger both ADCs with the timer 8 and have synchronous measurement, as long as they have the same sampling time, but I'd like to understand what went wrong anyways). Both ADCs have Scan Conversion enabled.
Now, as soon as the total ADC Conversion takes too long, I get an ADC Overrun. This can be achieved by reducing the Sampling Time, Resolution, Delay, or clock Prescaler. I get the same behaviour when I raise the Timer 8 Frequency.
What I find very odd is, that the overrun does not accur, when I make the ADC Conversion ver slow, for example by raising the Sampling Time to 480 Cycles, or raise the Prescaler to 8. Shouldn't I get an overrun exactly then, because the Conversion is slower than 50 kHz and therefore gets retriggered, before it is done?
So, why do I get an ADC overrun Problem with the code, I added below?
Why do I not get an ADC overrun Problem, when the whole ADC conversion takes a lot of time?
Am I right, that triggering both ADCs with the same timer should get me the results I wish to have?
I have added the code which does not work. As I've said, if I change for example the ADC Clock Prescaler to 8, it seems to work just fine.
