ADC output suddenly becomes constant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-26 7:17 AM
Hello,
I'm using the ADC on a STM32G431 to read 5 voltages at 20kHz. Everything works well, but suddenly the 5 channels "get stuck" or freeze, i.e. the value they measure becomes constant even though the voltages on the input pins still fluctuate. Sometimes the measured values resume to being correct again by themselves after a little while (like after 200 samples for instance), other times the values remain constant until I manually cycle the MCU power.
Some more details about the code architecture:
- I use 5 channels of the ADC2 in single-ended mode
- The sequence of 5 regular conversions (Single conversion mode) is triggered by TIM2's TRGO (update event at 20kHz)
- Data is stored in an array by DMA in circular mode. In the DMA ISR I have code to copy and log this data (at each DMA transfer complete interrupt).
Some info about my debugging so far:
- I've enabled ADC overrun interrupt and checked that it never gets fired
- Same goes for the DMA transfer error
- When logging the data I also log a timestamp (the value of a free running timer) to be certain that it's not my logging that gets stuck or that I'm seeing a scheduling problem. No issue there, the DMA ISR (and thus the logging) always gets called at 20kHz.
- Although the ADC measures are unrelated, this same PCB is also powering a motor. And it looks like it's when the motor has to performs an abrupt speed step that the ADC values get stuck. But I've looked at VDDA (= Vref+) with an oscilloscope, and there's no particular glitch to be seen when the values get stuck.
NB: this is surprisingly similar to this question by @FChen.3​ , but since no answer was given there I thought sharing my case still is useful.
Solved! Go to Solution.
- Labels:
-
ADC
-
STM32G4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-01 10:24 PM
Schematics is PWM out – R – C to gnd R and C need calculate based on freq and max pin current ...
Demodulated voltage can you measure on C.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-26 8:50 AM
Try configure MCU clock without PLL (HSI or HSE)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-31 1:22 AM
Thanks for you answer.
Sadly I can't do without the PLL (the MCU needs to be running at almost max speed), but still I've managed to reduce the PLL_N multiplication factor from 84 to 21. It looks like it's not helping though, the ADC still freezes.
Why do you point at the PLL? Is there some known bugs or undocumented limitations?
As suggested in the aforementioned thread, I've tried to restart the ADC + DMA when ADC freeze is detected. This indeed allows resuming ADC operation back to normal, but it's not really a solution.
Any other ideas of what could cause the observed ADC freezes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-13 7:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-27 1:19 AM
Hi Igor,
Thanks for your input. VDDA/VSSA pins are indeed well decoupled using 1uF+100nF ceramic caps placed ~1mm from the pins, but the caps are on the other side. I'll try and move them to the same side just in case.
Best,
ikrosoft
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-27 1:36 AM
Hi ikrosoft (Community Member),
What is the ADC clock? What is the "constant" ADC value (output word from ADC)? Which device revision are you using? Try to replace DMA with interrupt or polling method - to identify if the problem is in the DMA or not.
Regards
Igor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-02-28 4:08 AM
Hi All.
I am trying to use STM32F103 devices ADC channel number 0 and 1.
I checked the voltage over the pin IN0 and IN1 is 0.8V to 0.99V without giving any input to the pin due to this I am getting wrong value.
Could you please tell me the cause for this??
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-02-28 5:14 AM
Hi jtron.1,
If ADC input pin is floating then the input voltage is undefined and if you are measuring this floating pin the voltage is some residual voltage on sampling capacitor.
Why are you not providing some voltage on IN0 and IN1 an measuring it?
Regards
Igor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-02-28 8:51 AM
Thanks for the reply Igor.
Will residual voltage affect the accuracy?
When I try to pull this voltage down then I got 0000 reading on my display.
Can I use external pull down resistor.??
My concern is this the floating pin voltage is about 900mV to 1V so if I apply voltage less than 900mV will it work?
Because I want to measure voltage less than 600mV.
I did not provide yet as I was stuck in floating voltages I am getting on IN0 and IN1.
Thanks...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-01 7:46 AM
Hi jtron.1,
The voltage on floating ADC input pin is very weak - so external signal easily force own voltage on pin. The source signal impedance must follow the datasheet requirements: impedance less than 50 kOhm.
Regarding the voltage on IN0 and IN1 : what is the ADC result (data from ADC) for those channels? Are they zero or another values? And is this value fixed also if input volatge is changing?
Regards
Igor
