cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H735G-DK ADC accuracy

akbjk.1
Associate II

Hello.

I'm using the STM32H735G-DK and I run into a problem when using the ADC, so I made a very short CubeMX project to check this.

I started with a CubeMX configured board with no peripheral default initialisation.

Then I ticked ADC1 IN0. So by default it set it as 16bits conversion with software start. I changed the CPU clock to 550MHz.

In the generated project:

  • I'm starting the ADC conversion
  • Then I poll for the conversion completion
  • Then I read the ADC result and store it

HAL_ADC_Start(&hadc1);

HAL_StatusTypeDef status = HAL_ADC_PollForConversion(&hadc1, 1000);

adc_buff = HAL_ADC_GetValue(&hadc1);

The default pinout use the Arduino A2 pin (PA0_C). I connected the 3.3V on the ADC input. The ADC result is then 65535 which is fine. What is strange is that it doesn't change of a single lsb due to noise.

Then I connected the 0V on the ADC input. The result I get is 1000+-100lsb instead of 0.

Which basically mean that on a 16bit conversion, I have 10bits of noise.

  • I checked that the channel is set to single-ended
  • I checked that VDDA and GNDA are set to 3.3V and 0V.
  • I tried ADC2 instead
  • I tried ADC2 with another pin
  • I tried to slow the ADC clock down to 1MHz

But it still give me a huge offset. How to get rid of this?

The most unfortunate thing is that the audio recording is already not working, see

https://community.st.com/s/question/0D53W00000fnPbp/recording-audio-on-stm32h735-discovery-kit?t=1630236890446

So I'm using the ADC instead and I run into that terrible effect.

Best regards

1 ACCEPTED SOLUTION

Accepted Solutions
MasterT
Lead

You should try:

   if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, conf_in) != HAL_OK) {

and

   if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET_LINEARITY, conf_in) != HAL_OK) {

View solution in original post

3 REPLIES 3
MasterT
Lead

You should try:

   if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, conf_in) != HAL_OK) {

and

   if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET_LINEARITY, conf_in) != HAL_OK) {

akbjk.1
Associate II

.

I wasn't aware that the H7 had such embedded feature.

I tried to do ADC_CALIB_OFFSET only, but it appeared that when doing ADC_CALIB_OFFSET and ADC_CALIB_OFFSET_LINEARITY, the 3.3V result was better.

Now I have 0-186lsb for 0V and 64799-65119 for 3.3V, and that's much better.

Thanks a lot.