Skip to main content
Grozea.Ion
Associate III
June 13, 2017
Question

STM32F7 Disco ADC issue

  • June 13, 2017
  • 4 replies
  • 2051 views
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
This topic has been closed for replies.

4 replies

AvaTar
Senior III
June 13, 2017
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) ?

Jan Waclawek
Visitor II
June 13, 2017
Posted on June 13, 2017 at 09:24

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

JW

AvaTar
Senior III
June 13, 2017
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 ...
Grozea.Ion
Associate III
June 13, 2017
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

AvaTar
Senior III
June 13, 2017
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 ...

Grozea.Ion
Associate III
June 13, 2017
Posted on June 13, 2017 at 15:37

Hello AvaTar,

I have started to use cube when i switched to F7,  before i have only worked with F103 and i also did not used mxcube.

Until i will find examples that are not cube based i will have to stick to it due to the F7 complexity.

Now, if you have example that are not cube based can you share them? On the F7 i will use I2C, UART in DMA RxTx, EXTI and ADC, i have figure it myself how to deal with GPIO

:)

.

Once again, if you have non cube based examples please share them if you can.

Thanks

waclawek.jan
Super User
June 13, 2017
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

Grozea.Ion
Associate III
June 13, 2017
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.

Grozea.Ion
Associate III
June 13, 2017
Posted on June 13, 2017 at 18:10

Hello all and thank you for your support. I have found the issue of my ADC problem, is not software, it is the poor soldering of the CN5 connector on both boards, basically only PF6/PF7 can be used on my boards, for the other to work i need to apply pressure on the connector from side. I will return the boards a ask for new ones because all Arduino connectors are faulty.

Best regards,