在一个STM8L151L的最小系统上,用例程测试了芯片的ADC功能,发现测量的数据不怎么稳定,请问正常吗?
ADC程序:
int main( void )
{
char buf[64];
u16 u16_adc1_value;
float fVal;
CLK_PeripheralClockConfig (CLK_Peripheral_USART1,ENABLE); //开启ADC/USART时钟
CLK_PeripheralClockConfig (CLK_Peripheral_ADC1,ENABLE); //开启ADC/USART时钟
USART_Init(USART1,9600,USART_WordLength_8b,USART_StopBits_1,USART_Parity_No,USART_Mode_Tx);//USART初始化,9600,8N1
USART_Cmd (USART1,ENABLE); //使能USART
/* Enable ADC clock */
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
/* de-initialize ADC */
ADC_DeInit(ADC1);
/*ADC configuration
ADC configured as follow:
- Channel VREF
- Mode = Single ConversionMode(ContinuousConvMode disabled)
- Resolution = 12Bit
- Prescaler = /1
- sampling time 384 */
ADC_VrefintCmd(ENABLE);
delay_10us(3);
ADC_Cmd(ADC1, ENABLE);
ADC_Init(ADC1, ADC_ConversionMode_Single,
ADC_Resolution_12Bit, ADC_Prescaler_1);
ADC_SamplingTimeConfig(ADC1, ADC_Group_FastChannels, ADC_SamplingTime_384Cycles);
ADC_ChannelCmd(ADC1, ADC_Channel_Vrefint, ENABLE);
delay_10us(3);
while(1)
{
ADC_SoftwareStartConv (ADC1);//开启软件转换
while(!ADC_GetFlagStatus (ADC1,ADC_FLAG_EOC)); //等待转换结束
ADC_ClearFlag (ADC1,ADC_FLAG_EOC); //清除对应标志
u16_adc1_value=ADC_GetConversionValue (ADC1); //获取转换值
fVal = 1225;
fVal *= 4096;
fVal /= u16_adc1_value;
sprintf(buf,"VDD = %.1f mV \r\n",fVal);
USART1_SendStr(buf);
}
}
测量结果通过串口输出:
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3340.6 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3327.3 mV
VDD = 3320.7 mV
VDD = 3334.0 mV
VDD = 3329.5 mV
VDD = 3309.8 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3340.6 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3325.1 mV
VDD = 3318.5 mV
VDD = 3334.0 mV
VDD = 3345.1 mV
VDD = 3334.0 mV
VDD = 3301.1 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3329.5 mV
VDD = 3301.1 mV
VDD = 3336.2 mV
VDD = 3340.6 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3336.2 mV
VDD = 3336.2 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3334.0 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3334.0 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3336.2 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3318.5 mV
VDD = 3340.6 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3320.7 mV
VDD = 3329.5 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3345.1 mV
VDD = 3318.5 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3334.0 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3340.6 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3340.6 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3318.5 mV
VDD = 3318.5 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3318.5 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3309.8 mV
VDD = 3340.6 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3320.7 mV
VDD = 3318.5 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3334.0 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3320.7 mV
VDD = 3318.5 mV
VDD = 3309.8 mV
VDD = 3318.5 mV
VDD = 3301.1 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3334.0 mV
VDD = 3318.5 mV
VDD = 3318.5 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3309.8 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3318.5 mV
VDD = 3318.5 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3334.0 mV
VDD = 3334.0 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3309.8 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3325.1 mV
VDD = 3340.6 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3334.0 mV
VDD = 3301.1 mV
VDD = 3318.5 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3334.0 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3334.0 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3345.1 mV
VDD = 3318.5 mV
VDD = 3340.6 mV
VDD = 3336.2 mV
VDD = 3318.5 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3336.2 mV
VDD = 3320.7 mV
VDD = 3309.8 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3320.7 mV
VDD = 3334.0 mV
VDD = 3329.5 mV
VDD = 3301.1 mV
VDD = 3320.7 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3320.7 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3309.8 mV
VDD = 3320.7 mV
VDD = 3320.7 mV
VDD = 3309.8 mV
VDD = 3318.5 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3345.1 mV
VDD = 3338.4 mV
VDD = 3334.0 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3327.3 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3340.6 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3336.2 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3340.6 mV
VDD = 3318.5 mV
VDD = 3334.0 mV
VDD = 3318.5 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3340.6 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3345.1 mV
VDD = 3318.5 mV
VDD = 3336.2 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3336.2 mV
VDD = 3327.3 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3318.5 mV
VDD = 3340.6 mV
VDD = 3320.7 mV
VDD = 3338.4 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3336.2 mV
VDD = 3301.1 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3345.1 mV
VDD = 3318.5 mV
VDD = 3327.3 mV
VDD = 3320.7 mV
VDD = 3336.2 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3336.2 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3345.1 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3340.6 mV
VDD = 3336.2 mV
VDD = 3301.1 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3334.0 mV
VDD = 3340.6 mV
VDD = 3320.7 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3318.5 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3318.5 mV
VDD = 3318.5 mV
VDD = 3340.6 mV
VDD = 3301.1 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3320.7 mV
VDD = 3320.7 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3320.7 mV
VDD = 3320.7 mV
VDD = 3318.5 mV
VDD = 3318.5 mV
VDD = 3334.0 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3334.0 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3336.2 mV
VDD = 3338.4 mV
VDD = 3334.0 mV
VDD = 3309.8 mV
VDD = 3318.5 mV
VDD = 3301.1 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3334.0 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3338.4 mV
VDD = 3340.6 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3325.1 mV
VDD = 3309.8 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3309.8 mV
VDD = 3340.6 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3320.7 mV
VDD = 3301.1 mV
VDD = 3301.1 mV
VDD = 3329.5 mV
VDD = 3340.6 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3301.1 mV
VDD = 3340.6 mV
VDD = 3320.7 mV
VDD = 3329.5 mV
VDD = 3334.0 mV
VDD = 3338.4 mV
VDD = 3318.5 mV
VDD = 3329.5 mV
VDD = 3318.5 mV
VDD = 3338.4 mV
VDD = 3329.5 mV
VDD = 3329.5 mV
VDD = 3338.4 mV
VDD = 3301.1 mV
......
请问正常吗? |