本帖最后由 mzhboy 于 2015-10-25 21:42 编辑
原来在ADC1_IRQHandler()函数末尾使用 ADC1_ClearITPendingBit(ADC1_IT_EOCIE)来处理中断标志,结果发现ADC只进入一次中断。但是如果在主循环中读取ADC数据寄存器却能够读到。
后来发现坑爹的结构体
typedef enum
{
ADC1_IT_AWDIE = (uint16_t)0x010, /**< Analog WDG interrupt enable */
ADC1_IT_EOCIE = (uint16_t)0x020, /**< EOC interrupt enable */
ADC1_IT_AWD = (uint16_t)0x140, /**< Analog WDG status */
ADC1_IT_AWS0 = (uint16_t)0x110, /**< Analog channel 0 status */
ADC1_IT_AWS1 = (uint16_t)0x111, /**< Analog channel 1 status */
ADC1_IT_AWS2 = (uint16_t)0x112, /**< Analog channel 2 status */
ADC1_IT_AWS3 = (uint16_t)0x113, /**< Analog channel 3 status */
ADC1_IT_AWS4 = (uint16_t)0x114, /**< Analog channel 4 status */
ADC1_IT_AWS5 = (uint16_t)0x115, /**< Analog channel 5 status */
ADC1_IT_AWS6 = (uint16_t)0x116, /**< Analog channel 6 status */
ADC1_IT_AWS7 = (uint16_t)0x117, /**< Analog channel 7 status */
ADC1_IT_AWS8 = (uint16_t)0x118, /**< Analog channel 8 status */
ADC1_IT_AWS9 = (uint16_t)0x119, /**< Analog channel 9 status */
ADC1_IT_AWS12 = (uint16_t)0x11C, /**< Analog channel 12 status */
/* refer to product datasheet for channel 12 availability */
ADC1_IT_EOC = (uint16_t)0x080 /**< EOC pending bit */
} ADC1_IT_TypeDef;
定义的前两个都是关闭中断用的。前面的用法导致只能进入一次中断。
所以正确的清除中断标志是清EOC,两个函数ADC1_ClearITPendingBit(ADC1_IT_EOC)或者ADC1_ClearFlag(ADC1_FLAG_EOC)都是可以的
|