AC7811----ADC

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);
 }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值