cancel
Showing results for
Did you mean:

Associate II
Posted on January 04, 2017 at 19:51

Hi,

My vdd calculates to 3.49V but I measure it to 3.30V with a voltmeter.

The Vrefint calibration value at 0x1FFFF7BA is 1550.

Calculation is 3.3V * VrefintCalValue / AdcValue = 3.49V

I'm guessing it's my adc read value that is off, not the factory calibration value?

MCU is STM32F042G6Ux. ADC code is done in CubeMX.

ADC is clocked with a prescaler of /4 and sampletime is 239.5 cycles. So all signals should have plenty of time to settle between samples.

Code is inside this link ->

http://pastebin.com/G7bSzfyf

1 ACCEPTED SOLUTION

Accepted Solutions
Associate
Posted on November 13, 2017 at 12:32

Hi!

VREFINT_CAL is the result of conversion of 3.0 V by the ADC. So you should use 3.0 instead of 3.3 in you calculations.

I have the following formula in the reference manual for stm32l476:

VDDA = 3.0 V x VREFINT_CAL / VREFINT_DATA

http://www.st.com/content/ccc/resource/technical/document/reference_manual/02/35/09/0c/4f/f7/40/03/DM00083560.pdf/files/DM00083560.pdf/jcr:content/translations/en.DM00083560.pdf

18 REPLIES 18
Associate II
Posted on January 04, 2017 at 20:47

Getting somewhere. Found this piece of code inside the HAL:

/**

* @brief Perform an ADC automatic self-calibration

* Calibration prerequisite: ADC must be disabled (execute this

* @note Calibration factor can be read after calibration, using function

* HAL_ADC_GetValue() (value on 7 bits: from DR[6;0]).

* @retval HAL status

*/

.. and I used it in the ADC init routine.

Now I'm reading 1526, which is much nearer the calibration value and vdd calculates to 3.35V.

That is only 50mV offset from reality. Can I expect to get any closer than this?

Posted on January 15, 2017 at 21:48

Funny thing is that all though vdd readout is high (some 50mV off), other ADC readings that use the corrected vdd reading is close to spot on (1 or 2 mV off).

Senior
Posted on March 05, 2017 at 15:04

Hi

I am looking at this in interest as I am new to STM32 and am starting to look at the A/D side. I am concerned with the accuracy of the a/d as the chip I am using doesnt have VREF+ input.  Hope you dont mind me asking ,  in your calculation above, is the 3.3v because that is what you are reading on your volt meter, or is? I am thinking of running from a 3.6v battery , so the voltage will slightly drop as time goes by, and want to keep the same accuracy. Can anything be done with the VREFINT and  keep the accuracy?

Many Thanks

Scott

Posted on March 05, 2017 at 16:24

Expect that the calibration value is computed from a sample and current temperature. Don't expect it to come from long term thermal testing, or over a wide range of voltage or temperature. You might want to do some more thorough testing and profiling in your own test/calibration process, and over temperature.

You could apply your own reference voltage to the part via another ADC pin during test.

The reference is nominally 1.25V, as  I recall, check the documentation for your specific part. VREF+ will be bonded to VDDA if it is not brought to it's own pin.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Principal
Posted on March 05, 2017 at 19:06

Use the chip temperature measurement in the interpolated vdd calculations. I guess that when some STM32 consumes 100mA or more, the junction temperature should be compensated for possibly higher precision. If the vdd measurement need come for precise analog input measurements, then also consider an STM32 with differential input support.

Associate II
Posted on March 05, 2017 at 19:07

Clives expectations are correct, I measured 3.30... something volts manually.

Posted on March 19, 2017 at 10:16

Hi

I understand that the value of VREFINT at precisely

3.3V

is stored in memory during manufacture time. I know this is a silly question, but I assume the value read in from the VREFINT to calculate the chip voltage is not like a standard voltage reference in the sense it always stays the same same value?  As if it did there would be no way of calculating the vdd.  I am planning to run the processor at 2.5v , so I assume the value of VREFINT will change accordingly so the accurate value of the vdd can be calculated?

Many thanks from a beginner on th STM32

Scott

Associate II
Posted on March 19, 2017 at 11:12

Hi Scott,

You should read the sub-chapter of Temperature sensor and Internal voltage reference in ADC chapter of Reference Manual for the device you're using. Maybe you understand it better than I do, but this is what you can read from RM0091 for 'STM32F0x1/STM32F0x2/STM32F0x8 advanced ARM Â® -based 32-bit MCUs':

The internal voltage reference (V REFINT ) provides a stable (bandgap) voltage output for the

ADC and Comparators. V REFINT is internally connected to the ADC_IN17 input channel. The

precise voltage of V REFINT is individually measured for each part by ST during production

test and stored in the system memory area.Calculating the actual V DDA voltage using the internal reference voltage

The V DDA power supply voltage applied to the microcontroller may be subject to variation or

not precisely known. The embedded internal voltage reference (VREFINT) and its

calibration data acquired by the ADC during the manufacturing process at V DDA = 3.3 V can

be used to evaluate the actual V DDA voltage level.

The following formula gives the actual V DDA voltage supplying the device:

V DDA = 3.3 V x VREFINT_CAL / VREFINT_DATA

Where:

ï‚· VREFINT_CAL is the VREFINT calibration value

ï‚· VREFINT_DATA is the actual VREFINT output value converted by ADC

What I think is funny is that nowhere is it mentioned what Vrefint actually is. I know it doesn't matter, as long as you multiply the Vrefint/Vrefint_cal ratio by 3.3. If I had my project running rigth now I could tell you the value.

Posted on March 19, 2017 at 11:56

Hi Henrik