各位大神,我现在用STM32L151做一个项目用到外部中断。硬件上设计的PB0作为外部中断,但是调试的时候发现,PB0无论怎么弄都不进中断。我刚开始以为是配置有问题,于是我用PA0作为外部中断,用基本相同的配置,结果PA0可以正常的进中断。然后又试了PA5,PA6,PA12等,都可以正常进中断;但是当用PB14,PB12的时候,发现可以进中断,但是会一直进,搞的系统无法正常跑。
我现在想知道GPIOB是不是不能做外部中断?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
void EXTI_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource0);
EXTI_DeInit();
/* Clear the the EXTI line 11, 13 and 8 interrupt pending bit */
EXTI_ClearITPendingBit( EXTI_Line0);
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
一周热门 更多>