OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 4895|回复: 1

AIRCR_VECTKEY_MASK是什么意思

[复制链接]

8

主题

32

帖子

0

精华

初级会员

Rank: 2

积分
132
金钱
132
注册时间
2017-12-25
在线时间
27 小时
发表于 2017-12-25 23:50:11 | 显示全部楼层 |阅读模式
AIRCR:配置寄存器分组与自动复位控制


控制中断分组的是第8第9第10位。

如果要改变这三个位,要对16到31位写入0x05FA。#define AIRCR_VECTKEY_MASK 0x05FA0000就是这个意思了,
0x05fa对与AIRCR来说就是一个“入口钥匙”,只有对高16位写对了,才能对低16位写入。所以
AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
AIRCR = 0x05FA0000 | NVIC_PriorityGroup;
#define NVIC_PriorityGroup_2         ((uint32_t)0x500)
AIRCR = 0x05FA0000 | 0x500;



Access key; 0x05FA must be
written to this field to write to this
register, otherwise the write will
be ignored; the read-back value
of the upper half-word is 0xFA05
Indicates endianness for data: 1
for big endian (BE8) and 0 for little
endian; this can only change after
a reset

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

8

主题

32

帖子

0

精华

初级会员

Rank: 2

积分
132
金钱
132
注册时间
2017-12-25
在线时间
27 小时
 楼主| 发表于 2017-12-29 05:34:56 | 显示全部楼层
嵌套向量中断控制初始化,解读。
void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
{
  uint8_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;
          //air=0x500&0x700=0x500        0x700-0x500>>8 =0x2
          //这里是算出抢占优先级,所占的位数
    tmppre = (0x4 - tmppriority);//0x4-0x2=2
          //这里是算出抢占优先级后面要左移的次数
    tmpsub = tmpsub >> tmppriority;//0x0f>>2=3
          //这里是把响应优先级的有效位计算出来

    tmppriority = NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;//0x3<<2=0xc
          //抢占优先级向前移一定的位,根据(4-所占的位数)
    tmppriority |=  (uint8_t)(NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub);//0x0c|3=0xf
          //响应优先级与前面算出来的有效位做与,然后与抢占优先级进行组合
    tmppriority = tmppriority << 0x04;//因为IP是使用的高四位,所以左移4次=oxf0
        
    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);
  }
}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-5-19 19:43

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表