中断在FreeRTOS的TICKLESS_IDLE模式中

huangapple go评论44阅读模式
英文:

Interrupt in TICKLESS_IDLE mode of FreeRTOS

问题

I have some questions about tickless idle mode in FreeRTOS.

  • 在这种模式下,systick是否工作,还是当调用__WFI()后就停止工作,然后在退出__WFI()后再次工作?

  • 调用__WFI()将MCU置于低功耗模式,并使用中断唤醒MCU。但在FreeRTOS源代码port.c中,如下所示,在调用__WFI()之前会调用__disable_interrupt()。那么中断如何发生?

谢谢您的帮助。

英文:

I have some questions about tickless idle mode in FreeRTOS.

  • Does systick work in this mode, or systick just stop working when __WFI() has called and work again right after exiting __WFI() ?

  • Calling the __WFI() to make the MCU enter the low-power mode and using interrupts to wake up the MCU.
    But in FreeRTOS source code, port.c, as below. Before calling __WFI(), __disable_interrupt() is called.
    Hence, how can interrupt happen?

__weak void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
{
      ...
   __disable_interrupt();

   if( eTaskConfirmSleepModeStatus() == eAbortSleep )
   {
      ...
   }
   else
   {
      ...
      if( xModifiableIdleTime > 0 )
      {
         __WFI();
      }
      ...
      __enable_interrupt();
      ...
}

Thanks for your help.

答案1

得分: 0

  • 无论systick是否在低功耗模式下运行取决于systick的时钟源。这是特定于SOC的。如果在低功耗模式下将systick的时钟关闭,那么systick将不起作用。
  • WFI和中断之间的交互常常引起混淆。重要的是要记住,如果有更高优先级的异常被挂起,WFI将返回。WFI会忽略PRIMASK的值。在WFI返回后,中断仍然被禁用,直到明确启用为止。这是重要的行为,因为它允许在进入低功耗模式之前禁用中断并进行最终检查,也允许在WFI返回后但在处理任何IRQ之前执行其他操作。某些SOC需要在退出低功耗模式后执行一些清理活动。
英文:
  • Whether systick runs in low power mode depends upon the clock source to systick. It is SOC specific. If the clock to systick is turned off in low power mode, then systick does not function.
  • The interaction between WFI and interrupts causes much confusion. It is important to remember WFI returns if an exception is made pending that is of higher priority. WFI ignores the value of PRIMASK. After WFI returns interrupts are still disabled until explicitly enabled. This is important behavior as it allows interrupts to be disabled and a final check to be made before going into low power mode and it allows other actions to be taken after WFI returns but before any IRQ is handled. Some SOC's need to perform housekeeping activities after coming out of low power mode.

huangapple
  • 本文由 发表于 2023年5月15日 09:17:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76250339.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定