- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我可以在STM32F10x库中找到与NVIC_Init相关的问题,该问题与处理嵌套中断的优先级相关。我们知道,任何优先级值等于或高于 BASEPRI(在本例中为 11)的中断都可以调用 FromISR() FreeRTOS API 函数。
FreeRTOS 使用 15 级(最低优先级)。
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15
换句话说,FreeRTOS 允许我们以 15-11 优先级从 ISR 调用 API 函数(请参阅 xQueueSendToBackFromISR)。当我们初始化 NVIC 时,我们使用级别 #11
#define WRTU2_DMA1_SPI2_IRQ_PRIORITY (configLIBRARY_KERNEL_INTERRUPT_PRIORITY-4*)
/* DMA1 Channel4 interrupt setting */
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = WRTU2_DMA1_SPI2_IRQ_PRIORITY;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = WRTU2_DMA1_SPI2_IRQ_PRIORITY;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
所以,我们应该没问题。但问题是存在的。我决定检查 NVIC_Init。
根据STM32数据表中的信息,优先级寄存器为0xe000e40e(NVIC channel 14属于DMA1_Channel4中断)。
在 NVIC 初始化后,我可以从该寄存器读取 0x00 。这意味着 NVIC channel #14 在系统中具有最高优先级。
它会导致所有问题。
我添加了最简单的修复NVIC->IP[DMA1_Channel4_IRQn] = 0xF0;并且系统不会再出现故障。这样,我们当前的问题就解决了。
当然,我尝试分析NVIC_Init中发生了什么
**
* @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);
}
}
因此,我将类似的测试代码添加到我的应用程序中,看看它如何转换所有值
uint32_t NVIC_IRQChannelPreemptionPriority=0xFF,NVIC_IRQChannelSubPriority=0xFF;
int32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;
tprintf("\n\rSCB->AIRCR=0x%08x",SCB->AIRCR);
tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;
tprintf("\n\rtmppriority=0x%08x",tmppriority);
tmppre = (0x4 - tmppriority);
tmpsub = tmpsub >> tmppriority;
tprintf("\n\rtmppre=0x%08x",tmppre);
tprintf("\n\rtmpsub=0x%08x",tmpsub);
tmppriority = (uint32_t)NVIC_IRQChannelPreemptionPriority << tmppre;
tmppriority |= NVIC_IRQChannelSubPriority & tmpsub;
tmppriority = tmppriority << 0x04;
tprintf("\n\rtmppriority=0x%08x",tmppriority);
有日志
SCB->AIRCR=0xfa050000
tmppriority=0x00000007
tmppre=0xfffffffd
tmpsub=0x00000000
tmppriority=0x00000000
注意,即使我为两个输入参数指定 0xFF,它也会返回 0x00。
我对这种行为感到非常惊讶。这是一个库函数。
人们使用它很多年了。所以,我真的很困惑我能在那个函数中找到问题。
可能与应用中断和复位控制寄存器(SCB_AIRCR)有关地址偏移:0x0C复位值:0xFA05 0000所需权限:特权AIRCR 为异常模型提供优先级分组控制,为数据提供字节序状态访问和重置系统的控制。
注意,在库源中我可以看到#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
因此,看起来我们在 16 位半字节中有某种 BIG 与 LITTLE ENDIAN 字节顺序。
您对这个问题有什么建议或了解吗?
最佳答案
我发现了问题,问题是我应该使用 NVIC_SetPriorityGrouping(3); 3 表示 cortex-m3。
然后它提供4位抢占优先级和0位次优先级。最后,当我像这样启动时,它按我的预期工作。
/* DMA1 Channel4 interrupt setting */
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 11;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
关于c - STM32F103处理嵌套中断的优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53700659/
int x = 1; System.out.println( x++ + x++ * --x ); 上面的代码打印出“5”,但我不明白怎么办?我一直为最后一个 x 取零,然后乘以仍然为 0 的第二个
我现在正在尝试使用 Preference 类 首选项 pfrOfThis = Preferences.userNodeForPackage(this) 出现错误: “类 java.util.prefs
用下面的代码 import sys print "Hello " + sys.argv[1] if len(sys.argv) > 1 else "Joe" + "." 当我运行时 python he
我的网页包含: td { padding-left:10px; } 引用的样式表包含: .rightColumn * {margin: 0; padding: 0;} 我在 rightc
使用 JPA 我有一个关于 CascadeTypes 的问题。 例如: @ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST,
下面的“括号”是怎么写的? val words = List("foo", "bar", "baz") val phrase = "These are upper case: " + words ma
我只是想知道,对于以下代码,编译器是否单独使用关联性/优先级或其他一些逻辑来评估。 int i = 0, k = 0; i = k++; 如果我们根据关联性和优先级进行评估,postfix ++具有比
我设置了一个 Azure FrontDoor 服务,以主/备份类型的方式将流量分配给两个 API 管理服务。就像我希望所有流量都流向我的主要 APIM 服务一样,如果我碰巧关闭该服务(假装中断),那么
这是一个简单的 CSS: /* Smartphones (portrait and landscape) ----------- */ @media only screen and (min-devi
我设置了一个 Azure FrontDoor 服务,以主/备份类型的方式将流量分配给两个 API 管理服务。就像我希望所有流量都流向我的主要 APIM 服务一样,如果我碰巧关闭该服务(假装中断),那么
来自 Programming Perl pg 90,他说: @ary = (1, 3, sort 4, 2); print @ary; 排序右侧的逗号在排序之前求值,而左侧的逗号在排序之
+----+------------+------+ | id | title | lang | +----+------------+------+ | 1 | title 1 EN |
如何使用 Java 获取 DiffServe 代码点 (DSCP) 整数的优先级部分?我预计它涉及位移位,但由于某种原因,我似乎无法获得我期望的值。 最佳答案 假设我理解正确,只需向右执行 3 位逻辑
我有下一个运行良好的 js 函数: $(function () { $(".country").click(function () { var countries = Arra
int a[3]={10,20,30}; int* p = a; cout << *p++ << endl; 根据 wikipedia ,后缀++的优先级高于解引用,*p++应该先运行p++再解引用结
我想在优先读取归档后解决这种类型的表达式 2+3/5*9+3-4 这是我尝试解决该任务的代码我该如何解决这个问题 while ( !inputFile.eof() ) { getline( inp
我正在玩 Rhino 并注意到这种奇怪的行为似乎是运算符优先级: js> {}+{} NaN js> ''+{}+{} [object Object][object Object] js> ''+({
我想遍历文件列表并检查它们是否存在,如果文件不存在则给出错误并退出。我写了下面的代码: FILES=( file1.txt file2.txt file3.txt ) for file in ${FI
我正在执行级联 SELECT: SELECT * FROM x WHERE a = 1 AND b = 2 AND c = 3 => If nothing found, try: SELECT * F
即将参加考试,我正在参加之前的考试。 问题: 当两个或多个样式表规则应用于同一元素时,以下哪种类型的规则将优先? 一个。任何来自浏览器的声明 b.有用户来源的正常声明 C。作者来源正常声明 d.文档级
我是一名优秀的程序员,十分优秀!