void ADC_Config(void)
{
ADC_InitType adcConfig;
memset(&adcConfig, 0, sizeof(adcConfig));
ADC_TrigSourceType adcTrigSourceConfig;
memset(&adcTrigSourceConfig, 0, sizeof(adcTrigSourceConfig));
adcConfig.dataAlign = ADC_DataAlign_Right;
adcConfig.scanMode = ENABLE;
adcConfig.continousMode = DISABLE;
adcConfig.disContinousModeOnRegularGroup = DISABLE;
adcConfig.disContinousModeOnInjectGroup = DISABLE;
adcConfig.injectAutoMode = DISABLE;
adcConfig.discNum = 0;
/* USER CODE END MSP_ADC_Init 0 */
GPIO_SetFunc(GPIO_PA14, GPIO_FUNC_1);// ADC_IN7
ADC_Init(ADC, &adcConfig);
ADC_SetClockPrescaler(ADC, 4);
adcTrigSourceConfig.regularTrigSource = ADC_TrigSource_Internal;
adcTrigSourceConfig.injectTrigSource = ADC_TrigSource_Internal;
ADC_TrigSourceInit(ADC, &adcTrigSourceConfig);
ADC_DMACmd(ADC, DISABLE);
ADC_SetRegularGroupLength(ADC, 1);
ADC_Cmd(ADC, ENABLE);
}
unsigned int GetAD_RES()//压力传感器采样
{
ADC_SetRegularGroupSequence(ADC, 1, ADC_CHANNEL_AD7);
ADC_ChannelSampleTimeSel(ADC, ADC_CHANNEL_AD7, ADC_SampleTime_6Cycle);
ADC_SoftwareStartRegularConvCmd(ADC, ADC_ENABLE);//开始ADC规则组转换
while(!ADC_GetIntFlag(ADC,ADC_FLAG_EOC));
return ADC_GetRegularConversionValue(ADC);
}
AC7811----ADC
最新推荐文章于 2024-11-10 21:58:29 发布