本帖最后由 ljmf5 于 2017-4-6 18:34 编辑
楼主能否把代码贴出来看看,我的外部中断进入不了
代码如下:
void EXTI7_config(void)
{
GPIO_InitPara GPIO_InitStructure;
EXTI_InitPara EXTI_InitStructure;
NVIC_InitPara NVIC_InitStructure;
/* Enable the KEY Clock */
RCC_AHBPeriphClock_Enable(RCC_AHBPERIPH_GPIOA, ENABLE);
RCC_APB2PeriphClock_Enable(RCC_APB2PERIPH_CFG, ENABLE);
// GPIO_PinAFConfig(GPIOA, GPIO_PINSOURCE7, GPIO_AF_8);
/* Configure Button pin as input */
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PUPD_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_7;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Enable and set key EXTI Interrupt to the lowest priority */
NVIC_InitStructure.NVIC_IRQ = EXTI4_15_IRQn;
NVIC_InitStructure.NVIC_IRQPreemptPriority = 2;
NVIC_InitStructure.NVIC_IRQSubPriority = 0;
NVIC_InitStructure.NVIC_IRQEnable = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Connect key EXTI Line to key GPIO Pin */
SYSCFG_EXTILine_Config(EXTI_SOURCE_GPIOA, EXTI_SOURCE_PIN7);
/* Configure key EXTI line */
EXTI_InitStructure.EXTI_LINE = EXTI_LINE7;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LINEEnable = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_ClearIntBitState(EXTI_LINE7);
}
static unsigned int i;
void EXTI4_15_IRQHandler(void)
{
if(EXTI_GetIntBitState(EXTI_LINE7) != RESET)
{
printf("i=%d\r\n", i++);
EXTI_ClearIntBitState(EXTI_LINE7);
}
}
|