本帖最后由 Herojie 于 2018-1-4 22:59 编辑
我项目中用到了外部中短线8-15,当EXTI9_5_IRQn|EXTI15_10_IRQn这两个中断同时开启时,就根本进不去中断,关闭其中任意一个,另一个中断源下的中短线都可以进入,如何能同时两个中断都能工作正常呢。不知道问题出在哪里,搞了一天。
各路大神,原子哥,给个思路吧。[mw_shl_code=c,true]#include "EXIT.H"
#include "delay.h"
#include "usart.h"
#include "tim.h"
#include "PWM.H"
#include "gpio.h"
/***************************************************************************
éèÖÃμç»úÏTλ¿a1ض˿ú
ST1_S1---PD8 ST1_S2---PD9
ST2_S1---PD10 ST2_S2---PD11
ST3_S1---PD12 ST3_S2---PD13
ST4_S1---PD14 ST4_S2---PD15
****************************************************************************/
void EXIT_Init(void)
{
EXTI_InitTypeDef EXTI_Initstucture; //¶¨òå½á11ìå±äá¿
NVIC_InitTypeDef NVIC_Initstucture;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG,ENABLE); //ê1ÄüSYSCFGê±Öó
//3õê¼»ˉIO¿úÎaêäèë
GPIO_InitTypeDef GPIO_Initstucture;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE); //ê1ÄüPDê±Öó
GPIO_Initstucture.GPIO_Pin=GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|
GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
GPIO_Initstucture.GPIO_Mode=GPIO_Mode_IN;
GPIO_Initstucture.GPIO_Speed=GPIO_Speed_100MHz;
GPIO_Initstucture.GPIO_PuPd=GPIO_PuPd_UP;
GPIO_Init(GPIOD,&GPIO_Initstucture);//GPIODÅäÖÃ
/*************ó3éäÖD¶ÏÏß*******/
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD,EXTI_PinSource8);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD,EXTI_PinSource9);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD,EXTI_PinSource10);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD,EXTI_PinSource11);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD,EXTI_PinSource12);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD,EXTI_PinSource12);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD,EXTI_PinSource14);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD,EXTI_PinSource15);
/* ÅäÖÃËùóDÖD¶ÏÏß*/
EXTI_Initstucture.EXTI_Line=EXTI_Line8|EXTI_Line9|EXTI_Line10|EXTI_Line11|
EXTI_Line12|EXTI_Line13|EXTI_Line14|EXTI_Line15;
//Ñ¡ÔñËùóDÖD¶ÏÏß
EXTI_Initstucture.EXTI_Mode=EXTI_Mode_Interrupt; //Ñ¡ÔñÖD¶ÏÄ£ê½
EXTI_Initstucture.EXTI_Trigger=EXTI_Trigger_Falling; //Ñ¡ÔñϽμÑØ′¥·¢
EXTI_Initstucture.EXTI_LineCmd=ENABLE; //ê1ÄüÖD¶Ï
EXTI_Init(&EXTI_Initstucture); //ÖD¶ÏÅäÖÃ
NVIC_Initstucture.NVIC_IRQChannel=EXTI9_5_IRQn|EXTI15_10_IRQn; //ËùóDía2¿ÖD¶Ï
NVIC_Initstucture.NVIC_IRQChannelPreemptionPriority=0x01; //ÇàÕ¼óÅÏ輶0
NVIC_Initstucture.NVIC_IRQChannelSubPriority=0x02; //×óóÅÏ輶2
NVIC_Initstucture.NVIC_IRQChannelCmd=ENABLE; //ê1Äüía2¿ÖD¶Ïí¨μà
NVIC_Init(&NVIC_Initstucture);//ía2¿ÖD¶Ïí¨μàÅäÖÃ
}
void EXTI9_5_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line8)!=RESET) //ST1_S1ÖD¶Ï
{
STA_LED=!STA_LED;
EXTI_ClearITPendingBit(EXTI_Line8);
}
if(EXTI_GetITStatus(EXTI_Line9)!=RESET) //ST1_S2ÖD¶Ï
{
STA_LED=!STA_LED;
EXTI_ClearITPendingBit(EXTI_Line9);
}
}
void EXTI15_10_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line10)!=RESET) //ST2_S1ÖD¶Ï
{
EXTI_ClearITPendingBit(EXTI_Line10);
}
if(EXTI_GetITStatus(EXTI_Line11)!=RESET) //ST2_S2ÖD¶Ï
{
EXTI_ClearITPendingBit(EXTI_Line11);
}
if(EXTI_GetITStatus(EXTI_Line12)!=RESET) //ST3_S1ÖD¶Ï
{
EXTI_ClearITPendingBit(EXTI_Line12);
}
if(EXTI_GetITStatus(EXTI_Line13)!=RESET) //ST3_S2ÖD¶Ï
{
EXTI_ClearITPendingBit(EXTI_Line13);
}
if(EXTI_GetITStatus(EXTI_Line14)!=RESET) //ST4_S1ÖD¶Ï
{
EXTI_ClearITPendingBit(EXTI_Line14);
}
if(EXTI_GetITStatus(EXTI_Line15)!=RESET) //ST4_S2ÖD¶Ï
{
EXTI_ClearITPendingBit(EXTI_Line15);
}
}
[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>