cancel
Showing results for 
Search instead for 
Did you mean: 

The STM32L433 adc isnt too accurate.

SSmit.13
Senior

Hi

I have a STM32L433 processor on a 4 layer board with own ground plane, and below is circuit for VDDA input. I have set the VREF+ to 2.5v, and checked this with my meter, and its perfect (and isnt connected to anything).

I placed an accurate 1.026v DC onto the analogue input , and used an easy HAL example (12 bit) to read the ADC. I read the digital value of 1988 , which works out to 1.213v (2.5/4096)*1988 , which isnt the same. Looking on the scope, and the signal looks clean , and same with the power input 3.3v. I dont understand why it isnt accurate. Anyone any idea?

 MX_ADC1_Init();

 HAL_ADCEx_Calibration_Start(&hadc1,ADC_SINGLE_ENDED);

 while (1)

 {

    HAL_ADC_Start(&hadc1);

    HAL_ADC_PollForConversion(&hadc1,HAL_MAX_DELAY);

    raw=HAL_ADC_GetValue(&hadc1);

 }

0693W00000aJfNIQA0.png

9 REPLIES 9
AScha.3
Chief III

first check: is your Vref really used -> connect adc in to vref+ , read; then to gnd, read. 4096+0? (about +/- few counts).

then with cer.cap 100nF or so, on adc in to gnd, put the test voltage...read.

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

Show you VREF+ circuit, and show how you have your 1.026V ref connected (1.026V really? or was that a typo on 1.024V?). If you VREF+ is drooping (not enough capacitance, or caps too far from VREF+ pin) that could explain the difference.

What's the impedance of the 1.026V source? Try increasing sampling time, see datasheet.

JW

Hi

Im not great with impedance , but what I am trying to do is measure the input voltage. See below picture. The output of the divider goes right into the ADC. If I stuck it through an opamp as a buffer, would this improve it?

Cheers

Scott

0693W00000aJhXeQAK.png 

The reason why input impedance matters is, that it has to fully charge the sampling capacitor during the sampling phase.

Opamp follower is never a bad idea, but if high input impedance and too short sampling time is the primary problem, it should be enough to increase the sampling time.

0693W00000aJi65QAC.png 

JW

Hi

Thanks for the reply. As I was using the HAL (easier for testing), I set the sample rate to 247 and 640 , but still had the same result.

Strange that I read 1.213v from a 1.026v input, I would have thought it would be the other way around.

Cheers

Scott

raptorhal2
Lead

See Section 3.17 in the data sheet.

The answer comes out real close if you are on the internal 2.048V reference buffer.

A resistor divider external buffer may need the Figure 5 capacitors to provide a clean reference. A 1.0 uF will probably be OK for the mystery capacitor.

Oh, it didn't occur to me that VREF+ is not connected to an external 2.5V reference, but is fed from the internal reference instead...

In that case, the "mystery capacitor" actually needs to have a relatively precise value (actually 1.0uF as said by @raptorhal2​  in parallel with the 100nF ceramics is just OK).

0693W00000aJib3QAC.pngJW

Hi

Sorry, I forgot to add the below to my picture above (see below). As per manual I have 100nf and 1uf to vref. As you see I already have a 1uf added.

Best Regards

Scott

0693W00000aJkSIQA0.png