程序在AD取样10次,取样结果差别很大如图
void ADC_Configuration()
{
ADC_InitTypeDef ADC_InitStructure;
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 2;
ADC_Init(ADC1, &ADC_InitStructure);
ADC_Init(ADC2, &ADC_InitStructure);
ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 5,ADC_SampleTime_239Cycles5);
ADC_RegularChannelConfig(ADC2,ADC_Channel_11,5,ADC_SampleTime_239Cycles5);
ADC_Cmd(ADC1, ENABLE);
ADC_Cmd(ADC2, ENABLE);
while(ADC_GetResetCalibrationStatus(ADC1));//等待ADC1校准重置完成
ADC_StartCalibration(ADC1);//开始ADC1校准
while(ADC_GetCalibrationStatus(ADC1));//等待ADC1校准完成
ADC_ResetCalibration(ADC2); //重置ADC1校准寄存器
while(ADC_GetResetCalibrationStatus(ADC2));//等待ADC1校准重置完成
ADC_StartCalibration(ADC2);//开始ADC1校准
while(ADC_GetCalibrationStatus(ADC2));//等待ADC1校准完成
ADC_SoftwareStartConvCmd(ADC1,ENABLE);
ADC_SoftwareStartConvCmd(ADC2,ENABLE);
}
请高手指教 |