CH32V207 PA3-7設(shè)置外部中斷,只有PA3-4能響應(yīng)中斷,PA5-7不能響應(yīng)中斷

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();
}


您好,看你附的代碼,并沒有對PA5-7的中斷進(jìn)行配置,附件為我的測試?yán)?,PA3、4、5、6、7都是沒有問題的,你可以參考一下。

icon_rar.gifCH32V307 EXTI.zip



可以了,當(dāng)時寫時候以為5-7對應(yīng)的也是EXTI5_IRQn到EXTI7_IRQn但是IDE報錯就沒寫了,沒留意到5-7對應(yīng)的是EXTI9_5_IRQn.


只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频