手臂睡眠模式进入和退出差异WFE、WFI

2023-11-24

我对 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 相同?


您将在 Cortex-M 上看到的主要唤醒机制是中断,即 WFI(等待中断)。在我见过的所有实现中,都会导致内核时钟门控,尽管如果设计支持的话,有时可以使用更深的睡眠/更高的延迟模式。

WFE 在多处理器设计中更相关。

关于问题—— 1. Cortex-M 中的中断和系统处理程序非常相似,主要区别在于它们的触发方式。它们之间的架构有所区别,但实际上它们是相同的。

用于您的位表,它们实际上没有意义。每个 Cortex-M 实现对 WFI 期间发生的情况都有自己的解释。它可以从基本时钟门控到深度睡眠模式有所不同。有关真实情况,请参阅微处理器文档。

PRIMASK 不会影响从睡眠中醒来的行为。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

手臂睡眠模式进入和退出差异WFE、WFI 的相关文章

随机推荐