2023-09-13 11:54 AM
Using HAL_ADCEx_Calibration_Start() to calibrate the ADC. This function always returns HAL_ERROR.
Debugging shows its failing after it collects the 8 samples and attempting to disable the ADC is timing out. (ie. if ((HAL_GetTick() - tickstart) > ADC_DISABLE_TIMEOUT) is TRUE.)
Using CubeMX to generate drivers. CubeMX version 6.8.1
Note: ADC conversion are working IF I don't calibrate.
Thanks for your help.
Solved! Go to Solution.
2023-09-14 07:28 AM - edited 2023-09-14 07:35 AM
Hello @BrianB,
There is an issue on STM32G0 ADC during calibration due to delay needed between ADC enable and disable.
As a work-around: A minimum delay must be implemented between ADC enable and ADC disable.
The Fix proposal is to wait for 2 ADC clock cycles between ADC enable and disable (worst case: 256 CPU cycles) .
Our development team is very aware of this issue and working to resolve this, and the fix will be available in the next release of STM32CubeG0 firmware package.
Thank you for your understanding while we work on this.
Imen
2023-09-13 12:51 PM
Hello @BrianB and welcome to the Community,
Thank you for having reported this issue.
I check this and come back to you soon with update.
Imen
2023-09-13 01:33 PM - edited 2023-09-14 05:12 AM
Hello @BrianB
Have you ensured that the ADC is off because as you can see in the user manual of the STM32CUBEG0:
Also, in other boards, if the ADC work in a low frequency that can be a cause of error for HAL_ADCEx_Calibration_Start().
Best regards.
II
2023-09-14 07:28 AM - edited 2023-09-14 07:35 AM
Hello @BrianB,
There is an issue on STM32G0 ADC during calibration due to delay needed between ADC enable and disable.
As a work-around: A minimum delay must be implemented between ADC enable and ADC disable.
The Fix proposal is to wait for 2 ADC clock cycles between ADC enable and disable (worst case: 256 CPU cycles) .
Our development team is very aware of this issue and working to resolve this, and the fix will be available in the next release of STM32CubeG0 firmware package.
Thank you for your understanding while we work on this.
Imen
2023-09-14 12:11 PM
Hi,
The problem was low ADC frequency. It was 2 Mhz. I increased the ADC frequency to 8 MHz and the ADC calibration is working correctly.
Thanks for your help.
2023-09-15 09:34 AM
Really glad to know you overcame this problem.
Thank you once more for your understanding and contribution.