初中生
最后登录1970-1-1
在线时间 小时
注册时间2015-8-12
|
遇到的问题是 定义了三个外部中断,但是只有PE.7对应的中断能进,其他两个不行,求大神指导啊
exti.c文件中的代码
#include "exti.h"
static void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);//°ÑNVICÖD¶ÏóÅÏ輶·Ö×ééèÖÃÎaμúò»×é
NVIC_InitStructure.NVIC_IRQChannel=EXTI9_5_IRQn;//±íê¾òaÅäÖÃμÄλEXTIμú5~9ÏßμÄÖD¶ÏÏòá¿
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;//ê1ÄüÏàó|ÖD¶ÏÏòá¿μÄÖD¶ÏÏìó|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;//ÇàÕ¼óÅÏ輶
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0;//Ïìó|óÅÏ輶
NVIC_Init(&NVIC_InitStructure);
}
void EXTI_GPIOE_Config(void) // PE[5|6|7]
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
//ê1ÄüEXTIx(PE5)μÄê±Öóoíμú¶t1|ÄüAFIOê±Öó
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO,ENABLE);
NVIC_Configuration();//
/*¸ø½á11ìå±äá¿GPIO_InitStructure3õê¼»ˉ*/
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPD;//éÏà-êäèëÄ£ê½
GPIO_Init(GPIOE,&GPIO_InitStructure);
/*EXTIÖD¶ÏÏß¼°1¤×÷Ä£ê½ÅäÖÃ*/
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource5 | GPIO_PinSource6 | GPIO_PinSource7);//ê1óÃGPIO(PE[5|6|7]) ×÷Îaía2¿ÖD¶Ïêäèëòy½Å
//EXTI_InitStructure.EXTI_Line=EXTI_Line5;//½«DÅożì2aòy½ÅE5ᬽóμ½EXTI_Line5
EXTI_InitStructure.EXTI_Line=EXTI_Line5 | EXTI_Line6 | EXTI_Line7;//½«DÅożì2aòy½ÅE5¡¢6¡¢7ᬽóμ½EXTI_Line5¡¢6¡¢7
EXTI_InitStructure.EXTI_LineCmd=ENABLE;//ê1Äü
EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;//éèÖÃÎaÖD¶ÏÄ£ê½
EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Falling;//ϽμÑØÖD¶Ï
EXTI_Init(&EXTI_InitStructure);//½«3õê¼»ˉ½á11ìåμÄ2ÎêyD′èë¼Ä′æÆ÷
}
中断代码
#include "stm32f10x_it.h"
#include "relay.h"
#include "led.h"
void EXTI9_5_IRQHandler()
{
GPIO_SetBits(GPIOD,GPIO_Pin_13);//D5áá
GPIO_SetBits(GPIOG,GPIO_Pin_14);//D2áá
if(EXTI_GetITStatus(EXTI_Line5)!=RESET)//è·±£êÇ·ñ2úéúáËEXTI Line5 ÖD¶Ï£¨¼′±ê־λêÇ·ñÖÃ룩
{
GPIO_ResetBits(GPIOG,GPIO_Pin_14);//D2Ãe
GPIO_ResetBits(GPIOD,GPIO_Pin_13);//D5Ãe
GPIO_SetBits(GPIOB,GPIO_Pin_5);
EXTI_ClearITPendingBit(EXTI_Line5); //Çå3yÖD¶Ï±ê־λ
}
if(EXTI_GetITStatus(EXTI_Line6)!=RESET)//è·±£êÇ·ñ2úéúáËEXTI Line6 ÖD¶Ï£¨¼′±ê־λêÇ·ñÖÃ룩
{
GPIO_ResetBits(GPIOG,GPIO_Pin_14);//D2Ãe
GPIO_SetBits(GPIOE,GPIO_Pin_5);
EXTI_ClearITPendingBit(EXTI_Line6); //Çå3yÖD¶Ï±ê־λ
}
if(EXTI_GetITStatus(EXTI_Line7)!=RESET)//è·±£êÇ·ñ2úéúáËEXTI Line7 ÖD¶Ï£¨¼′±ê־λêÇ·ñÖÃ룩//R
{
GPIO_ResetBits(GPIOD,GPIO_Pin_13);//D5Ãe
// GPIO_SetBits(GPIOG,GPIO_Pin_14);//D2áá
// GPIO_ResetBits(GPIOG,GPIO_Pin_14);//D2Ãe
GPIO_ResetBits(GPIOB,GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_5);
EXTI_ClearITPendingBit(EXTI_Line7); //Çå3yÖD¶Ï±ê־λ
}
}
|
-
外部中断输入的3个引脚
|