2018-7-18 STM32 开发基础

2018-7-18 STM32 开发基础

NVIC中断优先级管理

首先给出MDK中与NVIC有关的寄存器定义的结构体:

typedef struct
{
  __IO uint32_t ISER[8]; //中断使能寄存器组,8*24=256个中断—》对应256个内核。对于stm32只需要使用ISER[0]与ISER[1]控制那60个中断即可                     /*!< Offset: 0x000  Interrupt Set Enable Register           */
       uint32_t RESERVED0[24];                                   
  __IO uint32_t ICER[8];//中断除能寄存器组,与ISER想反,清楚中断的使能。/*!< Offset: 0x080  Interrupt Clear Enable Register         */
       uint32_t RSERVED1[24];                                    
  __IO uint32_t ISPR[8];//中断挂起寄存器组,通过置1将正在进行的中断挂起,实现同级或更高级的中断 
  /*!< Offset: 0x100  Interrupt Set Pending Register          */
       uint32_t RESERVED2[24];                                   
  __IO uint32_t ICPR[8];  //中断解挂寄存器组                    /*!< Offset: 0x180  Interrupt Clear Pending Register        */
       uint32_t RESERVED3[24];                                   
  __IO uint32_t IABR[8]; //中断激活标志位寄存器组,只读寄存器,为1表示中断正在被执行 
  /*!< Offset: 0x200  Interrupt Active bit Register           */
       uint32_t RESERVED4[56];                                   
  __IO uint8_t  IP[240];//中断优先级控制寄存器组                      /*!< Offset: 0x300  Interrupt Priority Register (8Bit wide) */
       uint32_t RESERVED5[644];                                  
  __O  uint32_t STIR;                         /*!< Offset: 0xE00  Software Trigger Interrupt Register     */
}  NVIC_Type; 

对NVIC的优先级的说明

优先级分为两类,抢占优先级和响应优先级。其中抢占优先级比响应优先级优先。优先级中数字较小的优先。
且抢占优先级高的可以打断比之低的抢占优先级的中断,但是对于响应优先级却不能如此。
enter description here

posted @ 2019-05-23 09:33  liangzi20163933  阅读(123)  评论(0编辑  收藏  举报