碰到一个好奇怪的问题,PB4,PB5作为外部中断,所有配置PB4和PB5的配置都一样,PB4只要一配置为外部中断,不管上升沿还是下降沿始终进中断。PB5就不会。PB4的JTAG功能已经关闭。
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource4 | GPIO_PinSource5);
EXTI_InitStructure.EXTI_Line = EXTI_IMR_MR4;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_IMR_MR5;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Enable the EXTI4 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the EXTI9_5 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
void EXTI4_IRQHandler(void)
{
CLI();
if(EXTI_GetITStatus(EXTI_IMR_MR4) != RESET)
{
/* Clear the Key Button EXTI line pending bit */
// m_u8KeyPress_Flag = ENABLE;
EXTI_ClearITPendingBit(EXTI_IMR_MR4);
if ((GPIOB->IDR & GPIO_Pin_4) == (uint32_t)Bit_RESET)
{
m_u8KeyReadValue &= ~0x01;
}
else
{
m_u8KeyReadValue |= 0x01;
}
}
SEI();
}
void EXTI9_5_IRQHandler(void)
{
CLI();
if(EXTI_GetITStatus(EXTI_IMR_MR5) != RESET)
{
/* Clear the Key Button EXTI line pending bit */
EXTI_ClearITPendingBit(EXTI_IMR_MR5);
if ((GPIOB->IDR & GPIO_Pin_5) == (uint32_t)Bit_RESET)
{
m_u8KeyReadValue &= ~0x02;
}
else
{
m_u8KeyReadValue |= 0x02;
}
}
SEI();
}
大家看看哪里有问题啊? |