Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不明白嵌入式 C 中的以下操作是什么意思?
NVIC_ICPR |= 1 << (vector_number%32);
从参考手册中,我发现
但是为什么是32的模除呢?
它基本上是一个带有32位的寄存器。
32
这将删除一组中的一个或多个中断的挂起状态32。每个位代表一个中断号IRQ0 - IRQ31 (Vector number from 16 - 47)。写入 1 将删除挂起状态。写入 0 无效。
IRQ0 - IRQ31
(Vector number from 16 - 47)
重要的一点是你应该像这样使用它
NVIC_ICPR |= 1U << (vector_number%32);
这确保这将是无符号整数算术 - 它使您免于出现 UB 时出现的 UB vector_number=31。(chux 指出了这一点)。
vector_number=31