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(); }
热门产品 :
CH394: 以太网协议栈芯片