CH32V207 PA3-7设置外部中断,只有PA3-4能响应中断,PA5-7不能响应中断

CH32V207 PA3-7设置外部中断分别对应5个按键,现在只有PA3-4按下能响应中断,PA5-7按下不能响应中断.

PA3-7均配置为下拉.

代码如下:

void INTERRUPT_INIT(){

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA, ENABLE);
EXTI_InitTypeDef EXTERNAL_EXTI_InitStructure = {0};

GPIO_EXTILineConfig(board.manual_switch.port, board.manual_switch.pin);
GPIO_EXTILineConfig(board.pc1_switch.port, board.pc1_switch.pin);
GPIO_EXTILineConfig(board.pc2_switch.port, board.pc2_switch.pin);
GPIO_EXTILineConfig(board.pc3_switch.port, board.pc3_switch.pin);
GPIO_EXTILineConfig(board.pc4_switch.port, board.pc4_switch.pin);
EXTERNAL_EXTI_InitStructure.EXTI_Line = EXTI_Line3 | EXTI_Line4 | EXTI_Line5 | EXTI_Line6 | EXTI_Line7;
EXTERNAL_EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTERNAL_EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTERNAL_EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTERNAL_EXTI_InitStructure);

NVIC_InitTypeDef NVIC_InitStructure = {0};
NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

NVIC_InitTypeDef NVIC_InitStructure1 = {0};
NVIC_InitStructure1.NVIC_IRQChannel = EXTI4_IRQn;
NVIC_InitStructure1.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure1.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure1.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure1);

EXTI_ClearITPendingBit(EXTI_Line3);
EXTI_ClearITPendingBit(EXTI_Line4);
EXTI_ClearITPendingBit(EXTI_Line5);
EXTI_ClearITPendingBit(EXTI_Line6);
EXTI_ClearITPendingBit(EXTI_Line7);

}
void EXTI3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void EXTI4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));

void EXTI3_IRQHandler(void)
{
handleIRQ();
}

void EXTI4_IRQHandler(void)
{
handleIRQ();
}


您好,看你附的代码,并没有对PA5-7的中断进行配置,附件为我的测试例程,PA3、4、5、6、7都是没有问题的,你可以参考一下。

icon_rar.gifCH32V307 EXTI.zip



可以了,当时写时候以为5-7对应的也是EXTI5_IRQn到EXTI7_IRQn但是IDE报错就没写了,没留意到5-7对应的是EXTI9_5_IRQn.


只有登录才能回复,可以选择微信账号登录