请问使用cubeMX工具,进行了多路ADC采样,非DMA模式下的,按照网上资料,而配置管脚如下:
hadc.Instance = ADC1;
hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
hadc.Init.Resolution = ADC_RESOLUTION_12B;
hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc.Init.LowPowerAutoWait = DISABLE;
hadc.Init.LowPowerAutoPowerOff = DISABLE;
hadc.Init.ContinuousConvMode = DISABLE;
hadc.Init.DiscontinuousConvMode = DISABLE;
hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc.Init.DMAContinuousRequests = DISABLE;
hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;
ADC采样while如下:
for(int i=0;i<5;i++)
{
HAL_ADC_Start(&hadc); //启动ADC转换
HAL_ADC_PollForConversion(&hadc,10); //等待转换完成
adcBuf[i] = HAL_ADC_GetValue(&hadc); //获取转换值
printf("ch%d's ADC vaue = %4d\r\n",i,adcBuf[i]); //打印输出
}
printf("ADC stop\r\n\r\n");
HAL_ADC_Stop(&hadc);
但是这样采集下来就是第一路的数据,求问应该怎么写呢!
|