中断配置代码如下:
void bsp_InitKeyEXTI(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* 使能SYSCFG时钟 */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* 连接 EXTI Line8 到 PI8 引脚 */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOI, EXTI_PinSource8);
/* 连接 EXTI Line13 到 PC13 引脚 */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource13);
/* 连接 EXTI Line11 到 PI11 引脚 */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOI, EXTI_PinSource11);
/* 连接 EXTI Line3 到 PH3 引脚 */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOH, EXTI_PinSource3);
/* 连接 EXTI Line15 到 PH15 引脚 */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOH, EXTI_PinSource15);
/* 连接 EXTI Line7 到 PG7 引脚 */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOG, EXTI_PinSource7);
/* 连接 EXTI Line2 到 PH2 引脚 */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOH, EXTI_PinSource2);
/* 连接 EXTI Line11 到 PF11 引脚 */
// SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOF, EXTI_PinSource11);
/* 配置 EXTI LineXXX */
EXTI_InitStructure.EXTI_Line = EXTI_Line2 | EXTI_Line3 | EXTI_Line7 | EXTI_Line8 \
| EXTI_Line11 | EXTI_Line13| EXTI_Line15;
//EXTI_InitStructure.EXTI_Line = EXTI_Line13 | EXTI_Line11 | EXTI_Line8 | EXTI_Line7 ;
///////////////////////////////////////////////////////////////////////////////
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* 设置NVIC优先级分组为Group2:0-3抢占式优先级,0-3的响应式优先级 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
/* 中断优先级配置 最低优先级 这里一定要分开的设置中断,不能够合并到一个里面设置 */
NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x03;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x03;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
当 EXTI15_10_IRQn和EXTI9_5_IRQn的抢占优先级设置为一样,即0x02或者0x03时都能进入。但是一个设置为0x02一个设置为0x03时,设置为0x03那个的中断函数就是进不去,到底是什么情况呢? |