如题,使用STM8L151G4U6的COMP1作为比较器检测外部输入电压是否高于内部参考1.24V的时候,在
单片机没有休眠的情况下,可以正常触发中断,也可以读取比较器输出结果,但是一旦单片机进入halt();就无法中断唤醒了,又或者一直触发中断,不知道是哪里没设置好,有大神能帮忙分析下吗?下面贴出相关初始化代码:
GPIO_Init(GPIOA,GPIO_Pin_5,GPIO_Mode_In_FL_No_IT);
sta
tic void COMP_Config(void)
{
CLK_PeripheralClockConfig(CLK_Peripheral_COMP, ENABLE);
/* Connect internal reference voltage to COMP1 inverting input */
COMP_VrefintToCOMP1Connect(ENABLE);
/* close the analog switch number 0 */
SYSCFG_RIAnalogSwitchConfig(RI_AnalogSwitch_0, ENABLE);
/* close the analog switch number 1 */
SYSCFG_RIAnalogSwitchConfig(RI_AnalogSwitch_14, ENABLE);
/* close the I/O switch number 2 */
SYSCFG_RIIOSwitchConfig(RI_IOSwitch_2, ENABLE);// PA5
COMP_EdgeConfig(COMP_Selection_COMP1, COMP_Edge_Rising);
/* Enable COMP1 Interrupt */
COMP_ITConfig(COMP_Selection_COMP1, ENABLE);
/* Configure the event detection */
}
INTERRUPT_HANDLER(ADC1_COMP_IRQHandler,18)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
COMP_ClearITPendingBit(COMP_Selection_COMP1);
}