STM32外部中断,没有响应,什么情况,检查了两天还是没有找到问题

2019-07-21 04:31发布

#include "stm32f10x.h"
#include "exti.h"
#include "key.h"
#include "beep.h"
#include "led.h"
void EXIT_Init(void)
{
EXTI_InitTypeDef  EXTI_Initstuct;
NVIC_InitTypeDef  NVIC_Initstuct;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource3); //PE2  EXTI2   KEY2 ϽµÑØ´¥·¢
EXTI_Initstuct.EXTI_Line=EXTI_Line3;
EXTI_Initstuct.EXTI_Mode=EXTI_Mode_Interrupt;
EXTI_Initstuct.EXTI_Trigger=EXTI_Trigger_Falling;
EXTI_Initstuct.EXTI_LineCmd=ENABLE;
EXTI_Init(&EXTI_Initstuct);

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource4); //PE4  EXTI4  KEY0ϽµÑØ´¥·¢
EXTI_Initstuct.EXTI_Line=EXTI_Line4;
EXTI_Init(&EXTI_Initstuct);

NVIC_Initstuct.NVIC_IRQChannel=EXTI2_IRQn;
NVIC_Initstuct.NVIC_IRQChannelPreemptionPriority=0x02;
NVIC_Initstuct.NVIC_IRQChannelSubPriority=0x02;
NVIC_Initstuct.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_Initstuct);

NVIC_Initstuct.NVIC_IRQChannel=EXTI4_IRQn;
NVIC_Initstuct.NVIC_IRQChannelPreemptionPriority=0x02;
NVIC_Initstuct.NVIC_IRQChannelSubPriority=0x00;
NVIC_Initstuct.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_Initstuct);
}
void EXTI2_IRQHandler(void)
{
SysTick_Delay_Ms(10);
if(KEY2==0)   //°´¼üKEY2
{
  LED0=!LED0;
}   
EXTI_ClearITPendingBit(EXTI_Line2);  //Çå³ýLINE2ÉϵÄÖжϱê־λ  
}
void EXTI4_IRQHandler(void)
{
SysTick_Delay_Ms(10);
if(KEY0==0)
{
  LED0=!LED0;
  LED1=!LED1;
}
EXTI_ClearITPendingBit(EXTI_Line4);
}




友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。