2021-07-18 10:36 AM
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 72 Mhz and 12 Mhzfor ADC
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. I have printed a HEX value of output of function HAL_ADC_GetValue(&hadc1).
Solved! Go to Solution.
2021-07-18 11:42 AM
> 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
2021-07-18 11:42 AM
> 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
2021-07-19 04:57 AM
Thanks for the Reply. Your suggestion work perfectly.