左眼看不见 发表于 2017-9-14 11:54:12

请问ADC interrupt的出发条件是什么?

最近正在看STM32 固件库的user manual,看到里面关于ADC部分的例程,感觉还是有些糊涂。
以下时摘抄的代码:
1.Regular mode
/*##-3- Start the conversion process ######/
if(HAL_ADC_Start(&AdcHandle) != HAL_OK)
{ Error_Handler(); }
/*##-4- Wait for the end of conversion ######/
HAL_ADC_PollForConversion(&AdcHandle, 10);
if(HAL_ADC_GetState(&AdcHandle) == HAL_ADC_STATE_EOC_REG)
{
/*##-5- Get the converted value of channel ##*/
uhADCxConvertedValue = HAL_ADC_GetValue(&AdcHandle);
}
2.Interrupt mode
/*##-3- Start the conversion process ######/
if(HAL_ADC_StartIT(&AdcHandle) != HAL_OK)
{ Error_Handler(); }
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* AdcHandle)
{ /* Get the converted value of regular channel */
uhADCxConvertedValue = HAL_ADC_GetValue(AdcHandle);
}

两者的差别在于regular使用的是HAL_ADC_Start(&AdcHandle),interrupt使用的是HAL_ADC_StartIT(&AdcHandle) 。
这一点让我感到很困惑,使用regular时需要等待一定的采样时间,即HAL_ADC_PollForConversion(&AdcHandle, 10);,然后看HAL_ADC_GetState(&AdcHandle)的状态;
那interrupt进入中断的条件又是什么?因为它也需要软件运行HAL_ADC_StartIT(&AdcHandle)来开启,那中断意义何在?


MrJiu 发表于 2017-9-14 14:44:47

看一下手册里面的中断事件就知道了。。。当然了最基本的一个是,采集完成后的中断肯定是有的。。。。

五哥1 发表于 2017-9-17 21:28:35

触发条件当然要看手册
页: [1]
查看完整版本: 请问ADC interrupt的出发条件是什么?