ADC采集有很多种类型。
DMA传输一般为偶数,halfwold传输,uint16_t temp[4]={1,2,3,0};
//ADC_Enable(&hadc1);
HAL_ADCEx_Calibration_Start(&hadc1);
printf("test1\r\n");
HAL_ADC_Start_DMA(&hadc1,(uint32_t *)temp,2);
传输时在START_DMA函数里最后的值设置为两倍
非dma模式时则开启非连续转换,将每个通道单独设置一组,每次开启adc就采样一组。
HAL_ADC_Start(&hadc1);首先要开启adc1的通道
HAL_ADC_PollForConversion(&hadc1,10);//轮询等待adc转换完成,非dma模式使用
tem=HAL_ADC_GetValue(&hadc1);//获取adc的值
HAL_ADC_Stop(&hadc1);//关闭adc1的通道
HAL_ADCEx_Calibration_Start(&hadc1)//adc初始值校准