CH32V207 PA3-7設(shè)置外部中斷分別對應(yīng)5個按鍵,現(xiàn)在只有PA3-4按下能響應(yīng)中斷,PA5-7按下不能響應(yīng)中斷.
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(); }
熱門產(chǎn)品 :
CH339: 7端口多功能USB HUB控制器芯片