#简单AD检测
uint16_t ADC_Dat = 0 ; //定义接收AD值得变量
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1,0xffff); //等待检测结束
ADC_Dat=((HAL_ADC_GetValue(&hadc1))); //得到AD值
HAL_ADC_Stop(&hadc1); //结束AD检测
配置cubemx
上面使用的是轮询的方式所以中断开不开都行
#多通道ADCDMA方式检测
uint16_t ADCSample[6]={0};
void ADC(void)
{
HAL_ADCEx_Calibration_Start(&hadc1); //AD校准
HAL_ADC_Start_DMA(&hadc1,(uint32_t*)(ADCSample),3); //启动ADC1转换
//7一氧化、8天然气、9酒精
HAL_Delay(500) ;
}