cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 ADC measurement to Voltage

thomaslin66
Associate
Posted on March 29, 2016 at 14:36

Dear Friends,

I have a good experience in STM32F103, but trapped in STM32F407's ADC two weeks already. My HW plateform is STM32F407VGT.

Vref+ connect to 2.048V;   Vdda  connect to  3.1V

ADC resolution configured to be 12bits

Questions :

1. I can read and transfer ADC value to AdcValue, how to calculate to transfer ADCvalue to proper voltage? Is the formula :

  1-1. AdcValue x 3.1 / 4095... or

  1-2. AdcValue x (3.1 - 2.048) / 4095 ...or

  1-3. AdcValue x (2.048 -1.8) / 4095 .....or

  1-4. There is another proper formula..

Because I cannot find the proper reference in two weeks searching, while reading ADC-CH17, Vref (2.048V)  internal channel,  AdcValue is around 400.

#!stm32 #adc #stm32f4 #dac #filter
5 REPLIES 5
Posted on March 29, 2016 at 16:32

The +VREF external is the full-range value for the ADC, rather than 3.1V, not sure VDDA/VREF can be that different.

The VREFINT is NOT the same thing, it is an internal reference voltage. Nominally 1.21 V, from the Data Manual/Sheet

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
John F.
Senior
Posted on March 29, 2016 at 16:43

Assuming VSSA is at 0V and VREF is 2.048 then you should use

Vin=ADCReading / 4096 * VRef

So an ADCReading of 1234 would correspond to Vin of 0.617 Volts.

If it's more complicated than that I've misunderstood your question. For a helpful diagram and more information about errors and their causes see the Data Sheet section 5.3.21.

AvaTar
Lead
Posted on March 29, 2016 at 16:44

An ADC always uses a reference voltage to make it's conversion. (One might connect Vdda to Vref, making Vdda to Vref).

One bit of a <n>-bit ADC always represents Vref / 2^n.

For the 12-bit ADC of the STM32, that would be Vref / 4096.

In mathematical terms, the formula would be: Vmeasure = Measure_count * Vref / Max_count

Max_count is 2^12 in your case, i.e. 4095.

Be aware of possible pitfalls involving integer conversion/promotion in C language.

Posted on March 29, 2016 at 16:47

http://www.st.com/web/en/resource/technical/document/datasheet/DM00037051.pdf

Data Sheet from the product page for your part.

Search ''Embedded reference voltage'' or ''VREFINT''

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
thomaslin66
Associate
Posted on March 29, 2016 at 17:20

Dear Clive,

Deeply appreciate your coaching, I really missed this section.

I will keep paying efforts to familiar F4.

Thank you very very much.

Rds

Thomas