cancel
Showing results for 
Search instead for 
Did you mean: 

Get A1 Pin voltage with ADC stm32f2xx

damien2399
Associate II
Posted on February 21, 2012 at 08:36

Hi,

I tried to get A1 pin voltage on my stm32f2xx with ADC.

I have always the same value (3300mV) for temperature sensor, Vbat, VrefInt and A1 Pin ...

I used ADC VBAT_Measurement and ADC3_DMA examples of STM32F2xx_StdPeriph_Lib and I read always the same value.

If someone has a solution to fix this problem.

Thanks.
7 REPLIES 7
raptorhal2
Lead
Posted on February 21, 2012 at 22:56

It isn't clear which ADCs you are using for each channel. Section 10.3.3 of the F2 reference manual states:

Note: The temperature sensor, VREFINT and the VBAT channel are available only on the master

ADC1 peripheral.

For the A1 problem, check that ADC3 is available on your processor version, and that the A1 pin has a known signal not equal to 3.3V. If that is not the problem, provide a program listing.

Cheers, Hal

damien2399
Associate II
Posted on February 22, 2012 at 08:57

Thank you for your fast answer Hal.

I know that the temp. sensor, VBAT and VREFINT are on ADC1 peripheral, but in datasheet of STM32F205x, I read A1 pin is on ADC123 channel 1.

I tried with ADC1 channel 1 and with ADC3 channel and the result is same ...

I get back converted value and I apply the formula : voltage = (convertedValue * 3300) / 0xFFF.

After that I have always 52800mV value for voltage.

domen23
Associate II
Posted on February 22, 2012 at 09:37

> I get back converted value and I apply the formula : voltage = (convertedValue / 0xFFF) * 3300.

That should get you 0. C basics, integer math. a/b (where a<b, and both positive) will produce a 0
damien2399
Associate II
Posted on February 22, 2012 at 09:48

Yes, the formula I applied is : voltage = ( convertedValue * 3300 ) / 0xFFF

And not ( voltage = ( convertedValue / 0xFFF ) * 3300 )

Sorry for the mistake.

damien2399
Associate II
Posted on February 22, 2012 at 13:36

Nobody had this problem or a similar ?

If someone has a functional source code configuring and using ADC ...
raptorhal2
Lead
Posted on February 22, 2012 at 15:55

Myself and another forum user had a similar problem with the F4 where the answer was a full 16 bits. I don't have an F2 peripheral library to inspect, but it is the basis for the F4 library I am using, so try the following fix.

The F4 ADC1_Init structure has 7 parameters, you have initialized only 6. Add the following line:

  ADC_InitStructure.ADC_ExternalTrigConv = 0;

Cheers, Hal

damien2399
Associate II
Posted on February 22, 2012 at 16:11

Thank you Hal,

I tried with this parameter, and the value I received isn't 52800 anymore, it's now 3300, but it's not the real voltage ( I measure it manually).