cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 Disco ADC issue

Grozea.Ion
Associate II
Posted on June 13, 2017 at 08:09

Hello all,

I am trying to read the ADC value from PA0 pin on a STM32F7 Disco board but without any success.

The issue is that the ADC reading is acting as the pin is floating

I suspect that the initialization code is not correct due to the fact that if i change the the Pull parameter to PULLUP/DOWN the behavior of the ADC value stays the same.

I have try to run also the example ADC_RegularConversion_DMA from STM32Cube_FW_F7_V1.7.0 but the behavior of the value is the same (i run the code on 2 different new boards)

I have attached the ADC code for review.

Can someone help me figure it out what is wrong here?

Thanks

#adc-reads #stm32f7-discovery
11 REPLIES 11
AvaTar
Lead
Posted on June 13, 2017 at 08:18

  sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;

Perhaps the ADC input is actually 'floating'.

What are your timing requirements and attached analog input hardware (impedance) ?

Grozea.Ion
Associate II
Posted on June 13, 2017 at 10:22

Hi,

Thank you for your replys. 

With ADC I intend to read a battery voltage from time to time

I have also tested 480cycles and the result is the same, also i am using a 10k to test the ADC, the pot is connected to 3.3V

Posted on June 13, 2017 at 09:24

IMO 5V-tolerant pins disconnect pullup/pulldown when switched to analog mode.

JW

Posted on June 13, 2017 at 09:44

Perhaps I was a little cryptic.

I meant, 3 cycles is a

very

short sample time. If there is no adequate analog input driver, the value seems to float ...
Posted on June 13, 2017 at 10:08

0690X00000607JsQAI.png
Posted on June 13, 2017 at 10:20

Thinking I agree with you.

It has nothing to do with pull-up/pull-down configuration. It rather sounds like a deeper understanding of a SA-ADC is missing.

Posted on June 13, 2017 at 13:23

int main(void)

{

    HAL_Init();

    SystemClock_Config();

    MX_GPIO_Init();

    MX_ADC3_Init();

    HAL_ADC_Start(&hadc3);

    while (1)

    {

        //HAL_ADC_Start(&hadc3);

        HAL_ADC_PollForConversion(&hadc, 100);

        ADCValue = HAL_ADC_GetValue(&hadc);

        //HAL_ADC_Stop(&hadc3);

    }

}

Where is hadc defined?

JW

Posted on June 13, 2017 at 12:05

I don't use Cube, so I won't comment on the full code.

I used to take provided examples for a specific peripheral (ADC in this case) and compared it with my code in such cases.

Assuming a proper signal on the ADC input pin, the issue was usually with the configuration.

Not sure what Cube is supposed to do here automatically, and how reliable ...

Posted on June 13, 2017 at 15:28

Hi,

It is in main, extern ADC_HandleTypeDef hadc3;

Edit: Sorry, i have copied/paste the code, but the hadc 3 is correctly defined in adc.c and main.c

in the archive the 

extern ADC_HandleTypeDef hadc3; is missing.