STM8L探索套件學(xué)習(xí)筆記-EXTI外部中斷(二)
首先我們把KEY的GPIO設(shè)置為輸入中斷使能
GPIO_Init(KEY_PORT,KEY_PIN,GPIO_Mode_In_FL_IT);
然后配置中斷1為下降沿低電平觸發(fā)
EXTI_SetPinSensitivity(EXTI_Pin_1, EXTI_Trigger_Falling_Low);
設(shè)置中斷的優(yōu)先級(jí)
ITC_SetSoftwarePriority(EXTI1_IRQn, ITC_PriorityLevel_1);
開(kāi)全局中斷
enableInterrupts();
最后我們到中斷文件里面STM8L15X_it.c設(shè)置
INTERRUPT_HANDLER(EXTI1_IRQHandler, 9)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
GPIO_ToggleBits(GPIOE, GPIO_Pin_7);
Delay(0xFFFF);
EXTI_ClearITPendingBit(EXTI_IT_Pin1);
}
評(píng)論