2017-06-12 11:09 PM
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-discovery2017-06-12 11:18 PM
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
Perhaps the ADC input is actually 'floating'.
What are your timing requirements and attached analog input hardware (impedance) ?
2017-06-13 01:22 AM
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
2017-06-13 02:24 AM
IMO 5V-tolerant pins disconnect pullup/pulldown when switched to analog mode.
JW
2017-06-13 02:44 AM
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 ...2017-06-13 03:08 AM
2017-06-13 03:20 AM
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.
2017-06-13 04:23 AM
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
2017-06-13 05:05 AM
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 ...
2017-06-13 08:28 AM
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.