STM8L151C8T6 单片机,设置PA7为外部中断输入。无法触发中断。
#define Water_detect_Port GPIOA
#define Water_detect_Pin GPIO_Pin_7
GPIO_Init(Water_detect_Port,Water_detect_Pin,GPIO_Mode_In_FL_No_IT );
EXti_SetPinSensitivity(EXTI_Pin_7,EXTI_trigger_Falling);
EXTI_ClearITPendingBit(EXTI_IT_Pin7);
INTERRUPT_HANDLER(EXTI7_IRQHandler, 15)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
if(GPIO_ReadInputDataBit(Water_detect_Port,Water_detect_Pin)==RESET)
{
if((water_alarm!=module_water_data.status)&&(module_water_data.water_enable_status!=DISABLE))
{
printf("水浸报警触发\r\n");
module_water_data.cmd=water_alarm; //如果当前未执行报警程序,且PA7检测到被拉低,则开始报警
}
GPIO_Init(Water_detect_Port,Water_detect_Pin,GPIO_Mode_In_FL_No_IT );
}
EXTI_ClearITPendingBit(EXTI_IT_Pin7);
}
设置后无法进入EXTI7中断内。
asm("sim"); //关总中断
halInit();
asm("rim"); //开总中断
在初始货前关总中断,初始化后开总中断,无效。
请问还有哪些方面需要考虑?
EXTI7
|