This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32f103c8 ADC error, Constant error value and erratic output

I am trying to create ADC using STM32F103C8. Software i am using are:

a. STM32CubeMX

b. Keil Vision -- V5

c. Hercules to Monitor the Serial Output

Clock Setting of STM is

 

Code  :-

while (1)
  {
    /* USER CODE END WHILE */
        HAL_ADC_Start(&hadc1);
        HAL_ADC_PollForConversion(&hadc1,300);
        raw = HAL_ADC_GetValue(&hadc1);
        float vin = (double)raw*(3.3/4096);
        sprintf(msg1,"Vol = %.2f , HEX Value = %.4x \r\n",vin, raw);
        HAL_UART_Transmit(&huart1,(uint8_t*)msg1,sizeof(msg1),300);
    HAL_Delay(1000);
    /* USER CODE BEGIN 3 */
  }

i am getting a constant DC Output of around 1.69 Volt, when input volt at ADC is Zero (Screen Shot attached). After supplying any Voltage value between 0 - 3.3 Volt, output is varying contentiously between 0 to 3.3 Volt.

I have checked the input reference volt, it is 3.3 Volt. Can you suggest me how to resolve this issue. have printed a HEX value of output of function HAL_ADC_GetValue(&hadc1).

Parents
  • Issue got resolved. I got suggestion on other community, it worked..

    > i am getting a constant DC Output of around 1.69 Volt, when input volt at ADC is Zero

     

    I guess, you've left the input floating (unconnected) - ADC output is then undefined.

     

    Zero input means, that the input is connected to ground.

     

    JW

Reply
  • Issue got resolved. I got suggestion on other community, it worked..

    > i am getting a constant DC Output of around 1.69 Volt, when input volt at ADC is Zero

     

    I guess, you've left the input floating (unconnected) - ADC output is then undefined.

     

    Zero input means, that the input is connected to ground.

     

    JW

Children
No data