新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > STM32學習筆記--EXTI

STM32學習筆記--EXTI

作者: 時間:2016-11-11 來源:網(wǎng)絡 收藏
1、PA0 ... PF0 共用一個中斷標志 EXT0

PA1 ... PF1 共用一個中斷標志 EXT1
. .
. .
PA15... PF15共用一個中斷標志 EXT15
2、EXT5-9 共用一個中斷源
EXT10-15 共用一個中斷源
3、啟用中斷前,需ENABLE IO口的復用功能(AFIO)
4、設置中斷IO口
5、將IO口注冊到中斷線(將IO口映射到中斷線N)
例:GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource3); 將GPIOD.3注冊至                  

本文引用地址:http://m.butianyuan.cn/article/201611/316829.htm

                                 中斷線EXTILine3
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource4); 將GPIOD.4注冊至

中斷線EXTILine4
6、配置中斷
EXTI_InitStructure.EXTI_Line = EXTI_Line3;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; 中斷
= EXTI_Mode_Event 事件(觸發(fā)其它模塊)
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising 上升沿觸發(fā)
= EXTI_Trigger_Falling 下降沿觸發(fā)
= EXTI_Trigger_Rising_Falling 脈沖觸發(fā)
7、配置NVIC
8、如果使用庫函數(shù)寫中斷,要開放stm32f10x_conf.h中的相應中斷
----------------------------------------------------------------------------------------------------
例:
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO, ENABLE);
/* PD3,4,5,6按鍵輸入*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //上拉輸入
GPIO_Init(GPIOD, &GPIO_InitStructure);

/* 連接IO口到中斷線 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource3);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource4);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource5);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource6);
/* 配置中斷線3為邊降沿觸發(fā)*/
EXTI_InitStructure.EXTI_Line = EXTI_Line3;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/*其他為下降沿觸發(fā)*/
EXTI_InitStructure.EXTI_Line = EXTI_Line4|EXTI_Line5|EXTI_Line6;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);



關鍵詞: STM32EXT

評論


技術專區(qū)

關閉