如何在 Cortex-M0 中禁用 PendSV?

How to disable PendSV in Cortex-M0?

我有一个简单而愚蠢的问题,我可以通过写入 ICER 寄存器来禁用 Cortex-M0 架构中的 PendSV 异常吗?

正如'Cortex-M0 Devices Generic User Guide'所说:

Privileged software can disable the exceptions that Table 2-11 on page 2-20 shows as having configurable priority, see Interrupt Clear-enable Register on page 4-5.

可以在特权模式下完成。

但是在我的代码中,虽然我通过 NVIC_DisableIRQ(PendSV_IRQn) 禁用了 PendSV_IRQn,但是执行 SCB->ICSR |= SCB_ICSR_PENDSVSET 时会发生 PendSV 异常(PendSV_Handler ISR)! (我确定 MCU 处于特权模式 [CONTROL = 0])。我的错在哪里? 提前致谢。

ARMv6-M 体系结构参考手册说(在第 B1.5.1 节 "Overview of the exceptions supported"):

PendSV is permanently enabled,...

这似乎与您的引用相矛盾,因此其中一个肯定是错误的。您的实验表明 Cortex-M0 设备通用用户指南在这里是错误的。