按照原子哥视频上写的外部中断实验一步一步写的代码,用JTAG下载后按下键盘探索者开发板没反应

2019-07-20 12:35发布

#include "exti.h"
#include "delay.h" 
#include "led.h" 
#include "key.h"
#include "beep.h"


void EXTIX_Init(void)
{
   EXTI_InitTypeDef EXIT_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockLPModeCmd(RCC_APB2Periph_SYSCFG,ENABLE);

KEY_Init();

SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE,EXTI_PinSource4);

EXIT_InitStructure.EXTI_Line=EXTI_Line4;
EXIT_InitStructure.EXTI_LineCmd=ENABLE;
EXIT_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;
EXIT_InitStructure.EXTI_Trigger=EXTI_Trigger_Falling;
EXTI_Init(&EXIT_InitStructure);

NVIC_InitStructure.NVIC_IRQChannel=EXTI4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority=1;



NVIC_Init(&NVIC_InitStructure);
  
}


void EXTI4_IRQHandler(void)
{
  delay_ms(10);
if(KEY0==0)
{
 LED0=!LED0;
LED1=!LED1;

}
  EXTI_ClearITPendingBit(EXTI_Line4);

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