我在使用PB4 做外部中断时,要求下降沿进中断,但测试发现当我按下Key 时,可以进中断,但我释放Key时也进中断....不清楚为什么? PB4我也设置成输入上拉了. 能否看看我的code是否正确? 这是我初始化PB4 中断的code SYSCFG->EXTICR[1] |=0x01; //PB4 EXTI->IMR |=0x10; //Enable EXTI->EMR |=0x10; //Event EXTI->FTSR |=0x10; //Falling EXTI->PR |=0x10; // /* Enable and set Button EXTI Interrupt to the lowest priority */ NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 0x03; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); 以下是中断code void EXTI4_15_IRQHandler(void) { //if (EXTI_GetITStatus(TAMPER_BUTTON_EXTI_LINE) != RESET) if((EXTI->PR &0x10)==0x10) { test_cnt++; GPIOA->ODR = ~GPIOA->ODR; //EXTI_ClearITPendingBit(TAMPER_BUTTON_EXTI_LINE); EXTI->PR |=0x10; } } |
看看,,,,,, |