首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

STM32文档中关于NVIC寄存器说明的位置(2)

STM32文档中关于NVIC寄存器说明的位置(2)

NVIC_Init()这个函数:[url=][/url]
/**  * @brief  Initializes the NVIC peripheral according to the specified  *         parameters in the NVIC_InitStruct.  * @param  NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains  *         the configuration information for the specified NVIC peripheral.  * @retval None  */void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct){  uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;    /* Check the parameters */  assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd));  assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority));    assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority));      if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)  {    /* Compute the Corresponding IRQ Priority --------------------------------*/        tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;    tmppre = (0x4 - tmppriority);    tmpsub = tmpsub >> tmppriority;    tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;    tmppriority |=  NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;    tmppriority = tmppriority << 0x04;            NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;        /* Enable the Selected IRQ Channels --------------------------------------*/    NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =      (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);  }  else  {    /* Disable the Selected IRQ Channels -------------------------------------*/    NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =      (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);  }}
可以看到,它会去设置几个寄存器:NVIC的IP,ISER,ICER等等,NVIC是基址,为:
#define SCS_BASE            (0xE000E000)                              /*!< System Control Space Base Address */#define NVIC_BASE           (SCS_BASE +  0x0100)                      /*!< NVIC Base Address                 */#define SCB_BASE            (SCS_BASE +  0x0D00)                      /*!< System Control Block Base Address */#define NVIC                ((NVIC_Type *)          NVIC_BASE)        /*!< NVIC configuration struct         */
NVIC_Type为:
[url=][/url]
/** @addtogroup CMSIS_CM3_NVIC CMSIS CM3 NVIC  memory mapped structure for Nested Vectored Interrupt Controller (NVIC)  @{ */typedef struct{  __IO uint32_t ISER[8];                      /*!< Offset: 0x000  Interrupt Set Enable Register           */       uint32_t RESERVED0[24];                                     __IO uint32_t ICER[8];                      /*!< Offset: 0x080  Interrupt Clear Enable Register         */       uint32_t RSERVED1[24];                                      __IO uint32_t ISPR[8];                      /*!< 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];                      /*!< 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;                                               /*@}*/ /* end of group CMSIS_CM3_NVIC */
继承事业,薪火相传
返回列表