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

Gre*_*uhn 9 arm interrupt cortex-m

我是ARM架构的新手,我正试图围绕唤醒机制.

首先,我发现很难找到关于此的好消息.ARM的文档似乎非常简洁.

我想要了解的是,当Cortex(尤其是我正在使用的M0)将被唤醒时.

作为参考,我还咨询了以下内容:

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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

所以,有些问题:

1)首先,有人可以澄清之间的区别:

a)系统处理程序优先级寄存器

b)中断优先级寄存器.是否仅仅b)用于与系统无关的中断,例如pendSv?

现在适用于某些场景.我真的想了解由NVIC IRQ管理的场景如何启用NVIC待定PRIMASK

影响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相同?

小智 5

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

WFE 与多处理器设计更相关。

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

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

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