2024-08-08 01:20 PM - last edited on 2024-08-09 05:56 AM by Amel NASRI
I have a STM32U5G9 based board. I use 2 ADCs, ADC1 and ADC2 in independent mode.
I need to measure changing voltages with a lot digital noise filtering. I achieve this by setting ADC to sample the signal to a memory buffer via DMA, then averaging the noise, and if the average shows significant difference from the previous run - a notification is sent to the program to react.
The basic idea is simple - read data from ADC continuously, so - I used circular buffer.
After fixing the last HAL package issue with removed `HAL_PWREx_EnableVddA()` call (I added the call, it's necessary for the ADC to work), I managed to have my setup up and running.
However, the problem starts when I stop the conversion, and then want to start it up again. So:
2024-08-09 01:44 AM
Hello @HTD
According to the reference manual (RM0456) the software is allowed to set ADEN only when all bits of ADC_CR registers are 0 (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0) except for bit ADVREGEN which must be 1 (and the software must have wait for the startup time of the voltage regulator)
Please check if these conditions are ok on your setup before calling again HAL_ADC_Start_DMA.
2024-08-09 03:42 AM - edited 2024-08-09 04:11 AM
Ooopsie, I misread the register value. But it's not this:
As you see - the second pass (failed) passes through this check, so the CR state is valid.
It breaks later:
Line 4347 - just ADC_FLAG_RDY is not getting set in time.
Naturally, I checked what happens if I increase the timeout limit to 2 seconds, but obviously the ADC_FLAG_RDY doesn't get set at all, even one eternity later.
2024-08-09 03:56 AM
So the HAL driver starts ADC calibration, but it doesn't wait for it to finish?
2024-08-09 04:13 AM
@LCE wrote:So the HAL driver starts ADC calibration, but it doesn't wait for it to finish?
My bad, I misread the bit position, it's not a calibration issue. Please check my edited reply, when I provide more details from the debugger.