做了一个按键程序,但是进不了中断,程序如下,希望大牛指出问题void EXIT_KEY_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
EX
ti_InitTypeDef EXTI_InitStruct;
NVIC_InitTypeDef NVIC_InitStruct;
/* config the extiline(PC2) clock*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
/* Configyre P[A|B|C|D|E]0 NIVC */
NVIC_InitStruct.NVIC_IRQChannel = EXTI2_TS_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);
/* EXTI line gpio config(PC2) */
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; //
GPIO_Init(GPIOC, &GPIO_InitStruct);
/* EXTI line(PC2) mode config */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource2);
EXTI_InitStruct.EXTI_Line = EXTI_Line2;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Falling; //
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStruct);
}
void EXTI2_TS_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line2) != RESET)
{
Delay(2000);
if(EXTI_GetITStatus(EXTI_Line2) != RESET) /
{
EXTI_ClearITPendingBit(EXTI_Line2);
LEDON;
}
}
一周热门 更多>