void Ad_Init(void)
{
ADC1_DeInit();
ADC1_Init(ADC1_CONVERSIONMODE_SINGLE, ADC1_CHANNEL_6, ADC1_PRESSEL_FCPU_D4, ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL0, DISABLE);
ADC1_ScanModeCmd(DISABLE);
ADC1_DataBufferCmd(DISABLE);
ADC1_StartConversion();
for(uint8 i=0;i<100;i++);
ADC1_StartConversion();
}
Std_ReturnType Ad_Open(void *pData)
{
GPIO_Init(ADC1_GPIO,ADC1_PIN,GPIO_MODE_IN_FL_NO_IT);
return E_OK;
}
void Ad_Release(void *pData)
{
}
Std_ReturnType Ad_Scan(void)
{
if(ADC1_GetFlagStatus(ADC1_FLAG_EOC)==0x80)
{
ADC1_ClearFlag(ADC1_FLAG_EOC);
ADC1_StartConversion();
AdValue=ADC1_GetConversionValue();
return STD_TRUE;
}
return STD_FALSE;
}
这是adC的配置,输入口PB6接的Vcc3V。可是测出来看寄存器数据是1023.
错在哪了啊
|