AnsweredAssumed Answered

Read adc value from potentiometer

Question asked by beyens.jelle on May 2, 2017
Latest reply on May 3, 2017 by beyens.jelle

Hi

I am trying to read an adc value from a potentiometer with the following code:

 

         uint32_t readADCServo()
         {
         uint32_t adcValue, adcValueDegrees;
         HAL_ADC_Start(&hadc1);

         if (HAL_ADC_PollForConversion(&hadc1, 1)!=HAL_OK)
         {
           }

         while ((HAL_ADC_GetState(&hadc1) & HAL_ADC_STATE_REG_EOC ) == HAL_ADC_STATE_REG_EOC)
         {
         adcValue = HAL_ADC_GetValue(&hadc1);
         }
         HAL_Delay(1);

         adcValueDegrees = (adcValue * 180 / 4095) -90;

         return adcValueDegrees;
         }

 

 

The only value i get in adcValue is 536872088. No matter the position of the potentiometer.

Does anyone have a soluton for my problem?

Outcomes