当前位置:首页 > 单片机 > 单片机
[导读]一、关于中断中的结构体EXTI_InitTypeDef原型:uint32_t EXTI_InitTypeDef::EXTI_Line{uint32_t EXTI_LineFunctionalState EXTI_LineCmdEXTIMode_TypeDef EXTI_ModeEXTITrigger_TypeDef EXTI_Trigger}含有4个成员1、

一、关于中断中的结构体EXTI_InitTypeDef
原型:uint32_t EXTI_InitTypeDef::EXTI_Line
{
uint32_t EXTI_Line
FunctionalState EXTI_LineCmd
EXTIMode_TypeDef EXTI_Mode
EXTITrigger_TypeDef EXTI_Trigger
}含有4个成员
1、Specifies the EXTI lines to be enabled or disabled. This parameter can be any combination of
EXTI_Lines
EXTI_Lines的取值可以是下面的数字
#define EXTI_Line0 ((uint32_t)0x00001)
#define EXTI_Line1 ((uint32_t)0x00002)
#define EXTI_Line10 ((uint32_t)0x00400)
#define EXTI_Line11 ((uint32_t)0x00800)
#define EXTI_Line12 ((uint32_t)0x01000)
#define EXTI_Line13 ((uint32_t)0x02000)
#define EXTI_Line14 ((uint32_t)0x04000)
#define EXTI_Line15 ((uint32_t)0x08000)
#define EXTI_Line16 ((uint32_t)0x10000)
#define EXTI_Line17 ((uint32_t)0x20000)
#define EXTI_Line18 ((uint32_t)0x40000)
#define EXTI_Line19 ((uint32_t)0x80000)
#define EXTI_Line2 ((uint32_t)0x00004)
#define EXTI_Line3 ((uint32_t)0x00008)
#define EXTI_Line4 ((uint32_t)0x00010)
#define EXTI_Line5 ((uint32_t)0x00020)
#define EXTI_Line6 ((uint32_t)0x00040)
#define EXTI_Line7 ((uint32_t)0x00080)
#define EXTI_Line8 ((uint32_t)0x00100)
#define EXTI_Line9 ((uint32_t)0x00200)
#define IS_EXTI_LINE(LINE) ((((LINE) & (uint32_t)0xFFF00000) == 0x00) && ((LINE) != (uint16_t)0x00))
#define IS_GET_EXTI_LINE(LINE)
2、Specifies the new state of the selected EXTI lines. This parameter can be set either
to ENABLE or DISABLE
3、Specifies the mode for the EXTI lines. This parameter can be a value of EXTIMode_TypeDef
EXTIMode_TypeDef的取值有枚举类型


EXTI_Mode_Interrupt //中断模式
EXTI_Mode_Event //事件模式
4、Specifies the trigger signal active edge for the EXTI lines. This parameter can be a value of
EXTIMode_TypeDef
EXTIMode_TypeDef的取值有:
EXTI_Trigger_Rising //上升沿
EXTI_Trigger_Falling //下降沿
EXTI_Trigger_Rising_Falling // 上升下降沿


以上只是配置中断
然后还需要初始化
初始化函数: void EXTI_Init ( EXTI_InitTypeDef * EXTI_InitStruct )

作用 Initializes the EXTI peripheral according to the specified parameters in the EXTI_InitStruct

还有一个很重要的函数

void GPIO_EXTILineConfig(uint8_tGPIO_PortSource,

uint8_tGPIO_PinSource
)

这个函数的作用就是用于配置哪个GPIO的哪个管脚用于中断!!!!!!!


二、中断向量配置结构体 NVIC_InitTypeDef
作用: NVIC Init Structure definition.
参数成员:
uint8_t NVIC_IRQChannel
FunctionalState NVIC_IRQChannelCmd
uint8_t NVIC_IRQChannelPreemptionPriority
uint8_t NVIC_IRQChannelSubPriority
1、NVIC_IRQChannel
Specifies the IRQ channel to be enabled or disabled. This parameter can be a value of IRQn_Type
它的取值有
00170 NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */
00171 MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */
00172 BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */
00173 UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */
00174 SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */
00175 DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */
00176 PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */
00177 SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */
00178
00179 /****** STM32 specific Interrupt Numbers *********************************************************/
00180 WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */
00181 PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */
00182 TAMPER_IRQn = 2, /*!< Tamper Interrupt */
00183 RTC_IRQn = 3, /*!< RTC global Interrupt */
00184 FLASH_IRQn = 4, /*!< FLASH global Interrupt */
00185 RCC_IRQn = 5, /*!< RCC global Interrupt */
00186 EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */
00187 EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */
00188 EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */
00189 EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */
00190 EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */
00191 DMA1_Channel1_IRQn = 11, /*!< DMA1 Channel 1 global Interrupt */
00192 DMA1_Channel2_IRQn = 12, /*!< DMA1 Channel 2 global Interrupt */
00193 DMA1_Channel3_IRQn = 13, /*!< DMA1 Channel 3 global Interrupt */
00194 DMA1_Channel4_IRQn = 14, /*!< DMA1 Channel 4 global Interrupt */
00195 DMA1_Channel5_IRQn = 15, /*!< DMA1 Channel 5 global Interrupt */
00196 DMA1_Channel6_IRQn = 16, /*!< DMA1 Channel 6 global Interrupt */
00197 DMA1_Channel7_IRQn = 17, /*!< DMA1 Channel 7 global Interrupt
对于我的片子还有
00297 #ifdef STM32F10X_HD
00298 ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */
00299 USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */
00300 USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */
00301 CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */
00302 CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */
00303 EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
00304 TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */
00305 TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */
00306 TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */
00307 TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
00308 TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
00309 TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
00310 TIM4_IRQn = 30, /*!< TIM4 global Interrupt */
00311 I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
00312 I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
00313 I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */
00314 I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */
00315 SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
00316 SPI2_IRQn = 36, /*!< SPI2 global Interrupt */
00317 USART1_IRQn = 37, /*!< USART1 global Interrupt */
00318 USART2_IRQn = 38, /*!< USART2 global Interrupt */
00319 USART3_IRQn = 39, /*!< USART3 global Interrupt */
00320 EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
00321 RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */
00322 USBWakeUp_IRQn = 42, /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */
00323 TIM8_BRK_IRQn = 43, /*!< TIM8 Break Interrupt */
00324 TIM8_UP_IRQn = 44, /*!< TIM8 Update Interrupt */
00325 TIM8_TRG_COM_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt */
00326 TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */
00327 ADC3_IRQn = 47, /*!< ADC3 global Interrupt */
00328 FSMC_IRQn = 48, /*!< FSMC global Interrupt */
00329 SDIO_IRQn = 49, /*!< SDIO global Interrupt */
00330 TIM5_IRQn = 50, /*!< TIM5 global Interrupt */
00331 SPI3_IRQn = 51, /*!< SPI3 global Interrupt */
00332 UART4_IRQn = 52, /*!< UART4 global Interrupt */
00333 UART5_IRQn = 53, /*!< UART5 global Interrupt */
00334 TIM6_IRQn = 54, /*!< TIM6 global Interrupt */
00335 TIM7_IRQn = 55, /*!< TIM7 global Interrupt */
00336 DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */
00337 DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */
00338 DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */
00339 DMA2_Channel4_5_IRQn = 59 /*!< DMA2 Channel 4 and Channel 5 global Interrupt */
00340 #endif /* STM32F10X_HD */
2、第二个参数NVIC_IRQChannelCmd
作用:Specifies whether the IRQ channel defined in NVIC_IRQChannel will be enabled or disabled.
This parameter can be set either to ENABLE or DISABLE
3、第三个参数 IRQChannelPreemptionPriority
Specifies the pre-emption priority for the IRQ channel specified in NVIC_IRQChannel.
This parameter can be a value between 0 and 15
4、第四个参数 uint8_t NVIC_IRQChannelSubPriority
Specifies the pre-emption priority for the IRQ channel specified in NVIC_IRQChannel.
This parameter can be a value between 0 and 15

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

MCS-51单片机有两个外部中断源INT0和INT1,它们分别在P3.2和P3.3引脚出现低电平或下降沿信号时向单片机发出中断请求。外部中断可用于检测单片机外部发生的事件,如键盘敲击和特定脉冲发生的次数等。

关键字: 51单片机 外部中断

外部中断是单片机实时地处理外部事件的一种机制。具体指的是,当某种外部事件发生时,单片机的中断系统迫使CPU暂停正在执行的程序,转而去进行中断事件的处理;中断处理完毕后,又返回被中断的程序处,继续执行下去。这里我们以Nuc...

关键字: MCU 外部中断 ST

stm32f103zet6是一种嵌入式-微控制器的集成电路(IC),是由ST公司开发的STM32F1系列的其中一种,芯体尺寸是32位,速度是72MHz,程序存储器容量是256KB,程序存储器类型是FLASH,RAM容量是...

关键字: stm32f103zet6 datasheet 引脚图

STM32CubeMX是官方推荐的配置软件,而HAL库也是取代之前的库函数的通用库,所以STM32CubeMX+HAL库是当前主流的工程创建方式,HAL库的可移植性也高于被取代的库函数。 之前在[程序员小哈]的公众号中写...

关键字: LED 外部中断

1.ARM中一些常见英文缩写解释 MSB:最高有效位; LSB:最低有效位; AHB:先进的高性能总线; VPB:连接片内外设功能的VLSI外设总线; EMC:外部存储器控制器; MAM:存储器加速模块; VIC:向量中...

关键字: ARM THUMB I2C 外部中断

有时候,我们需要保存少量数据,但是用外扩的ROM又觉得不方便,这时候自然就想到了芯片内部是否自带flash(闪存),据我了解,stm32内部的应该是nor flash,因为如果是nand flash的话,肯定速度是跟不上...

关键字: Flash nor stm32f103zet6

定时器TIM3产生四路PWM波输出。首先介绍一下PWM吧,算是给自己充电,脉冲宽度调制(PWM),是英文“Pulse Width Modulation ”的缩写,简称脉宽调制,是利用微处理器的数字输出来对模拟电路进行控制...

关键字: pwm stm32f103zet6 定时器

/********************************文件所用资源1.外部中断0、1 定时中断0、1 串口中断2.端口:P3.0,P3.1,P3.3,P3.4,P3.5********************...

关键字: c51程序 串口中断 外部中断 定时中断

#include #include #include int main(void){MCUCR |= (1

关键字: AVR gcc编程 单片机 外部中断

进行串口配置的步骤一、初始化GPIO,配置GPIO模式一个结构体GPIO_InitTypeDef{GPIOMode_TypeDef GPIO_Mode//GPIO模式,输入,输出?uint16_t GPIO_Pin//哪...

关键字: stm32f103zet6 串口学习
关闭
关闭