cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745ZIT6 ADC error

MorisG_PE
Associate II

I'm encountering an issue with the ADC on my STM32H745ZIT6 microcontroller when reading voltages from a power supply. Here's the problem in detail:

I'm using the ADC to convert analog voltages from a power supply into digital values. However, I've noticed significant inaccuracies in the ADC readings across all voltage ranges. For example, when the power supply outputs 6V, the ADC reads 6.22V consistently, and similar deviations occur across other voltage levels.

I've ensured that the power supply voltages are stable and within the operating range specified for the ADC. The issue is persistent and does not seem to be related to specific voltage thresholds.

 

Has anyone else in the community encountered similar issues with the STM32H7 series ADC? If so, how did you resolve them? Any insights or suggestions on how to troubleshoot or resolve this issue would be greatly appreciated.

 

20 REPLIES 20

Ooo, yes.

Otherwise you get - what you get now. Precision undefined , without first doing calibration call.

see ds:

AScha3_0-1721291169061.png

 

ALWAYS do calibration first - not replace the poor chip. 🙂

.

If you feel a post has answered your question, please click "Accept as Solution".

What is the process of the calibration? the  HAL_ADCEx_Calibration_Start(..) is used at the startup and then getvalue gets the values and calibrates the ADC accordingly? Do most users calibrate it in this way?

After power up you have to do calibration (mode depends on what you want, differential or single ended input, + linearity calibration for best ( = as in ds) linearity ).

>HAL_ADCEx_Calibration_Start(..) is used at the startup and then getvalue gets the values and calibrates the ADC accordingly?

Right. But you have to do it !

 

 

>Do most users calibrate it in this way?

Come on - everyone has to do it. Expept you dont care for the result of an uncalibrated ADC, maybe ok, maybe not.

As you have seen. 🙂

rtfm

AScha3_0-1721292693175.png

 

If you feel a post has answered your question, please click "Accept as Solution".

Thanks for the reply :), is there a code reference for this process anywhere? 

Just have ...

HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET_LINEARITY, ADC_SINGLE_ENDED);

 

at program beginnning..before using ADC.

 

If you feel a post has answered your question, please click "Accept as Solution".

Thanks :), I will try your recommendation 

RolfStDK
Associate II

As i understood, HAL_ADCEx_Calibration_Start() should be called every "startup". Is there a way to call it self-calibration of the ADC once, save the calibration values (e.g. to internal eeprom) and every statup to recall the same self-calibration values?

I found and used:

HAL_ADCEx_LinearCalibration_GetValue(ADC_HandleTypeDef *hadc, uint32_t *LinearCalib_Buffer)
HAL_ADCEx_LinearCalibration_SetValue(ADC_HandleTypeDef *hadc, uint32_t *LinearCalib_Buffer)
 
I've called the self calibration with the offset linearity option:
//Calling once
HAL_ADCEx_Calibration_Start(&hadc3, ADC_CALIB_OFFSET_LINEARITY, ADC_SINGLE_ENDED))
uint32_t selfLinearCalib_Buffer[ADC_LINEAR_CALIB_REG_COUNT]; 
save_buff_to_eeprom(selfLinearCalib_Buffer);
HAL_ADCEx_LinearCalibration_GetValue(&hadc3, selfLinearCalib_Buffer);
 
//From that point on, every startup - a flag indicates ADC was already self-calibrated
load_buff_from_eeprom(selfLinearCalib_Buffer);
HAL_ADCEx_LinearCalibration_SetValue(&hadc3, selfLinearCalib_Buffer);
 
==> the setValue is not working, as the ADC is not calibrated as after HAL_ADCEx_Calibration_Start()
What am I missing?
Thanks in advance!
 

No - you just run

HAL_ADCEx_Calibration_Start(&hadc3, ADC_CALIB_OFFSET_LINEARITY, ADC_SINGLE_ENDED))

1x ...after program start .  Thats all. (no need set...get...factory value...etc.)

You get calibrated ADC at actual temperature etc.

Just if your program running 24/7  without any stop - maybe do calibration every some hours or days.

Or only at power up and then  never again, if you dont need best performance on long time.

If you feel a post has answered your question, please click "Accept as Solution".

Thanks for your prompt reply.

Right, this works fine, but I want to avoid changing the calibration every power up, meaning i want to have a one-time calibration per product life, as we do a manual calibration in addition to the ADC-self calibration. So trying to figure out how to save and retrieve the self-calibration done in HAL_ADCEx_Calibration_Start().

In addition to the linearity factors, you'll need to program the offset as well, which can be found in the ADC_CALFACT register. The reference manual goes into detail on this, including how to read/write values.

If you feel a post has answered your question, please click "Accept as Solution".