在线时间12 小时
UID414236
ST金币0
蝴蝶豆0
注册时间2013-1-23
初级会员
- 最后登录
- 1970-1-1
|
a0a.1 0b0c
我在使用过STM32F103的外部中断过程中,使用中断线PB4来做外部中断,当时配置忘记使能RCC_APB2Periph_AFIO时钟了,结果把PB4不能中断,但PA4却能中断!配置如下:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA| \
RCC_APB2Periph_GPIOB| \
RCC_APB2Periph_USART1| \
RCC_APB2Periph_AFIO, \\若这个不打开那么PB4中断,反而PA4可以中断。原因何在?
ENABLE);
void Interrupts_Config(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;//´ÓÓÅÏȼ¶
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void EXTI_Config(void) //
{
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource4);
EXTI_InitStructure.EXTI_Line = EXTI_Line4;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_GenerateSWInterrupt(EXTI_Line4);
}
void GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
不知道怎么回事?按道理,这个RCC_APB2Periph_AFIO没有使能是时钟,就不应该响应中断的! |
|