# stm32f103RE ADC returns fixed value

I am using 64 pin stm32f103RE, Keil and STM32Cube for my project, the problem is when I try to read ADC by polling or interrupt modes with HAL_ADC_GetValue(&hadc1), just a fixed number is returned (0xFF0F0000). AS the pin is float so some noise values must be shown instead.

I also tried ADC_GetConversionValue(ADC1) using CMSIS and Keil but the result was the same, for both polling and interrupt mode. What would be the reason, may it be something with ADC hardware problem?

• What would be the reason, may it be something with ADC hardware problem as every beginner you look for the hardware problems, compiler errors etc etc. You must remember - in almost 100% cases your code is wrong. Compiler and hardware is OK. Also do not ask questions without your code. Oct 16 '17 at 16:42
• Have you configured the GPIOs correctly? Have you clocked the GPIO? Have you clocked the ADC? Have you started the ADC? Have you configured the correct channels in the ADC? Are you triggering the ADC? Oct 16 '17 at 17:00
• GPIO is configured in HAL_ADC_MspInit() which is called by HAL_ADC_Init(). The last is called from MX_ADC1_Init() . This line "PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV2;" inside SystemClock_Config() shows that the adc is been clocked. I do triggering by software, also HAL_ADC_ConvCpltCallback() is been called and so I measure the value using HAL_ADC_GetValue(&hadc1). Oct 16 '17 at 23:01
• My code is also containing GPIO, SD 4-wire FATFS-SDIO and SPI which are working well. The whole code is massive in size so i prefered not to put it here in my question. Oct 16 '17 at 23:23