stm32 NVIC中断管理实现[直接操作寄存器](转)(2)
- UID
- 1029342
- 性别
- 男
|
stm32 NVIC中断管理实现[直接操作寄存器](转)(2)
ISER[2]:中断使能寄存器组
stm32可屏蔽中断共有60个,这里用了两个32位的寄存器,可以表示64个中断。stm32只用了前60位。 若要使能某个中断,则必须设置相应的ISER位为1。
具体每一位对应的中断关系如下:(参见 MDK下的 stm32f10x_nvic.h )
01 | #define WWDG_IRQChannel ((u8)0x00) /* Window WatchDog Interrupt */ |
02 | #define PVD_IRQChannel ((u8)0x01) /* PVD through EXTI Line detection Interrupt */ |
03 | #define TAMPER_IRQChannel ((u8)0x02) /* Tamper Interrupt */ |
04 | #define RTC_IRQChannel ((u8)0x03) /* RTC global Interrupt */ |
05 | #define FLASH_IRQChannel ((u8)0x04) /* FLASH global Interrupt */ |
06 | #define RCC_IRQChannel ((u8)0x05) /* RCC global Interrupt */ |
07 | #define EXTI0_IRQChannel ((u8)0x06) /* EXTI Line0 Interrupt */ |
08 | #define EXTI1_IRQChannel ((u8)0x07) /* EXTI Line1 Interrupt */ |
09 | #define EXTI2_IRQChannel ((u8)0x08) /* EXTI Line2 Interrupt */ |
10 | #define EXTI3_IRQChannel ((u8)0x09) /* EXTI Line3 Interrupt */ |
11 | #define EXTI4_IRQChannel ((u8)0x0A) /* EXTI Line4 Interrupt */ |
12 | #define DMA1_Channel1_IRQChannel ((u8)0x0B) /* DMA1 Channel 1 global Interrupt */ |
13 | #define DMA1_Channel2_IRQChannel ((u8)0x0C) /* DMA1 Channel 2 global Interrupt */ |
14 | #define DMA1_Channel3_IRQChannel ((u8)0x0D) /* DMA1 Channel 3 global Interrupt */ |
15 | #define DMA1_Channel4_IRQChannel ((u8)0x0E) /* DMA1 Channel 4 global Interrupt */ |
16 | #define DMA1_Channel5_IRQChannel ((u8)0x0F) /* DMA1 Channel 5 global Interrupt */ |
17 | #define DMA1_Channel6_IRQChannel ((u8)0x10) /* DMA1 Channel 6 global Interrupt */ |
18 | #define DMA1_Channel7_IRQChannel ((u8)0x11) /* DMA1 Channel 7 global Interrupt */ |
19 | #define ADC1_2_IRQChannel ((u8)0x12) /* ADC1 et ADC2 global Interrupt */ |
20 | #define USB_HP_CAN_TX_IRQChannel ((u8)0x13) /* USB High Priority or CAN TX Interrupts */ |
21 | #define USB_LP_CAN_RX0_IRQChannel ((u8)0x14) /* USB Low Priority or CAN RX0 Interrupts */ |
22 | #define CAN_RX1_IRQChannel ((u8)0x15) /* CAN RX1 Interrupt */ |
23 | #define CAN_SCE_IRQChannel ((u8)0x16) /* CAN SCE Interrupt */ |
24 | #define EXTI9_5_IRQChannel ((u8)0x17) /* External Line[9:5] Interrupts */ |
25 | #define TIM1_BRK_IRQChannel ((u8)0x18) /* TIM1 Break Interrupt */ |
26 | #define TIM1_UP_IRQChannel ((u8)0x19) /* TIM1 Update Interrupt */ |
27 | #define TIM1_TRG_COM_IRQChannel ((u8)0x1A) /* TIM1 Trigger and Commutation Interrupt */ |
28 | #define TIM1_CC_IRQChannel ((u8)0x1B) /* TIM1 Capture Compare Interrupt */ |
29 | #define TIM2_IRQChannel ((u8)0x1C) /* TIM2 global Interrupt */ |
30 | #define TIM3_IRQChannel ((u8)0x1D) /* TIM3 global Interrupt */ |
31 | #define TIM4_IRQChannel ((u8)0x1E) /* TIM4 global Interrupt */ |
32 | #define I2C1_EV_IRQChannel ((u8)0x1F) /* I2C1 Event Interrupt */ |
33 | #define I2C1_ER_IRQChannel ((u8)0x20) /* I2C1 Error Interrupt */ |
34 | #define I2C2_EV_IRQChannel ((u8)0x21) /* I2C2 Event Interrupt */ |
35 | #define I2C2_ER_IRQChannel ((u8)0x22) /* I2C2 Error Interrupt */ |
36 | #define SPI1_IRQChannel ((u8)0x23) /* SPI1 global Interrupt */ |
37 | #define SPI2_IRQChannel ((u8)0x24) /* SPI2 global Interrupt */ |
38 | #define USART1_IRQChannel ((u8)0x25) /* USART1 global Interrupt */ |
39 | #define USART2_IRQChannel ((u8)0x26) /* USART2 global Interrupt */ |
40 | #define USART3_IRQChannel ((u8)0x27) /* USART3 global Interrupt */ |
41 | #define EXTI15_10_IRQChannel ((u8)0x28) /* External Line[15:10] Interrupts */ |
42 | #define RTCAlarm_IRQChannel ((u8)0x29) /* RTC Alarm through EXTI Line Interrupt */ |
43 | #define USBWakeUp_IRQChannel ((u8)0x2A) /* USB WakeUp from suspend through EXTI Line Interrupt */ |
44 | #define TIM8_BRK_IRQChannel ((u8)0x2B) /* TIM8 Break Interrupt */ |
45 | #define TIM8_UP_IRQChannel ((u8)0x2C) /* TIM8 Update Interrupt */ |
46 | #define TIM8_TRG_COM_IRQChannel ((u8)0x2D) /* TIM8 Trigger and Commutation Interrupt */ |
47 | #define TIM8_CC_IRQChannel ((u8)0x2E) /* TIM8 Capture Compare Interrupt */ |
48 | #define ADC3_IRQChannel ((u8)0x2F) /* ADC3 global Interrupt */ |
49 | #define FSMC_IRQChannel ((u8)0x30) /* FSMC global Interrupt */ |
50 | #define SDIO_IRQChannel ((u8)0x31) /* SDIO global Interrupt */ |
51 | #define TIM5_IRQChannel ((u8)0x32) /* TIM5 global Interrupt */ |
52 | #define SPI3_IRQChannel ((u8)0x33) /* SPI3 global Interrupt */ |
53 | #define UART4_IRQChannel ((u8)0x34) /* UART4 global Interrupt */ |
54 | #define UART5_IRQChannel ((u8)0x35) /* UART5 global Interrupt */ |
55 | #define TIM6_IRQChannel ((u8)0x36) /* TIM6 global Interrupt */ |
56 | #define TIM7_IRQChannel ((u8)0x37) /* TIM7 global Interrupt */ |
57 | #define DMA2_Channel1_IRQChannel ((u8)0x38) /* DMA2 Channel 1 global Interrupt */ |
58 | #define DMA2_Channel2_IRQChannel ((u8)0x39) /* DMA2 Channel 2 global Interrupt */ |
59 | #define DMA2_Channel3_IRQChannel ((u8)0x3A) /* DMA2 Channel 3 global Interrupt */ |
60 | #define DMA2_Channel4_5_IRQChannel ((u8)0x3B) /* DMA2 Channel 4 and DMA2 Channel 5 global Interrupt */ |
系统中断这里没有申明,所以导致一些系统中断无法使用,比如 systick的中断 这个在 stm32上最方便的定时器Systick[操作寄存器+库函数] 已经做了分析
ICER[2]:中断清除寄存器组
结构同ISER[2],但是作用相反。 中断的清楚不是通过向ISER[2]中对应位写0实现的,而是在ICER[2]对应位写1清除的。
ISPR[2]:中断挂起控制寄存器组
每一位对应的中断和ISER是一样的。通过置1来挂起正在进行的中断,而执行同级或者更高级别的中断。
ICPR[2]:中断解挂寄存器组
结构和ISPR[2]相同,作用相反。置1将相应中断解挂。
IABR[2]:中断激活标志位寄存器组
中断和ISER[2]对应,如果为1,则表示该位所对应的中断正在执行。这是只读寄存器,由硬件自动清零。
IPR[15]:中断优先级控制的寄存器组
IPR寄存器组由15个32位寄存器组成。每个可屏蔽的中断占用8位,这样可以表示的可屏蔽中断为 15*4 =60个。而每个可屏蔽中断占用的8位并没有全部使用,而是只使用了高4位。这4位又分为抢占优先级和子优先级。抢占优先级在前,子优先级在后。而这两个优先级各占几位又要根据SCB->AIRCR中中断分组的设置来决定。 |
|
|
|
|
|