测试代码如下:
uint32_t ResultVolt = 0;
uint8_t i;
for(i=0; i<8; i++)
{ //等待转换完成
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
ResultVolt +=(uint32_t) ADC_GetConversionValue(ADC1);
}
ResultVolt = ResultVolt >> 3; //求平均(除8)
ResultVolt = (ResultVolt*3300) >> 12; //计算得到1000倍的电压值(整数值, 无小数点)
return ResultVolt;