我对 ARM 架构相当陌生,我正在尝试了解唤醒机制。
首先,我发现很难找到这方面的好信息。 ARM 的文档似乎对该主题非常简洁。
我想了解的是皮质(特别是我正在使用的 M0)何时会醒来。
作为参考,我还查阅了以下资料:
- WFI 和 WFE 指令以及事件信号的用途是什么?
- 为什么使用WFE指令时处理器会进入待机状态,而使用WFI指令时处理器不会进入待机状态?
WFE 指令的文档是:
3.7.11. WFE
Wait For Event.
Syntax
WFE
Operation
If the event register is 0, WFE suspends execution until
one of the following events occurs:
an exception, unless masked by the exception mask registers or the current
priority level
an exception enters the Pending state, if SEVONPEND in the
System Control Register is set
a Debug Entry request, if debug is enabled
an event signaled by a peripheral or another processor in a
multiprocessor system using the SEV instruction.
If the event register is 1, WFE clears it to 0 and completes immediately.
For more information see Power management.
Note
WFE is intended for power saving only. When writing software assume
that WFE might behave as NOP.
Restrictions
There are no restrictions.
Condition flags
This instruction does not change the flags.
Examples
WFE ; Wait for event
The WFI:
3.7.12. WFI
Wait for Interrupt.
Syntax
WFI
Operation
WFI suspends execution until one of the following events occurs:
an exception
an interrupt becomes pending, which would preempt if PRIMASK was clear
a Debug Entry request, regardless of whether debug is enabled.
Note
WFI is intended for power saving only. When writing software assume
that WFI might behave as a NOP operation.
Restrictions
There are no restrictions.
Condition flags
This instruction does not change the flags.
Examples
WFI ; Wait for interrupt
那么,一些问题:
1)首先,有人可以澄清以下之间的区别:
a) 系统处理程序优先级寄存器
b) 中断优先级寄存器。
是否只是 b) 用于与系统无关的中断,例如 pendSv?
现在来看一些场景。我真的很想了解这些场景是如何由以下因素控制的:
NVIC 中断请求使能
NVIC 待定
普利玛斯克
影响WFE和WFI的进出。
因此这些位的各种组合会产生 8 种不同的场景
{NVIC_IRQ 启用、NVIC 待定、PRIMASK}。
我已经补充了目前为止我的模糊理解。请帮我整理一下这张桌子。
- 000 - 不阻止 WFE 或 WFI 进入,但也没有唤醒条件
- 001 - 作为 000
- 010 - 挂起如何影响 WFE 和 WFI 进入睡眠模式?
- 011 - 我猜这里的答案是 010 但可能有不同的唤醒条件?
- 100 - 我猜 WFE 和 WFI 都进入低功耗模式并退出低功耗模式没有问题。
- 101 - WFE 和 WFI 电源模式退出有什么区别吗?
- 110 - 不知道!
- 111 - 不知道!
我在这里排除了优先级,因为我还不太关心异常处理顺序。
排除 SEV 和事件信号,如果 SEVONPEND 为 0,WFE 的行为是否与 WFI 相同?