gpt4 book ai didi

c - 嵌入式RTOS停止系统

转载 作者:行者123 更新时间:2023-12-03 00:35:17 25 4
gpt4 key购买 nike

我正在 Cortex M0 上学习 FreeRTOS。 (同时,我也在学习皮质......)。我在 8 位 MCU 方面拥有丰富的经验。

我正在阅读 FreeRTOS 的新手教程,并且了解如何设置基本任务和空闲守护进程。

我意识到我并不真正理解 FreeRTOS 正在做什么来管理内核的底层计时机制。这就引出了一个大问题......

当您想要关闭设备时,关闭 RTOS 的理想方法是什么?不要让设备闲置,而是将您的 MCU 置于最深的关闭状态(无论您如何调用它)。

在任务之间空闲似乎很简单,但是关闭 MCU 并确保其保持关闭状态,并且 RTOS 内核不会触发中断或其他东西来唤醒 MCU ......?

最佳答案

这是深度 sleep 模式/掉电模式,对于8位MCU,这位于ATmega128RFA1数据表第159页http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-8266-MCU_Wireless-ATmega128RFA1_Datasheet.pdf中(使用唤醒源)在此模式下,所有内部定时器均被禁用

在 freeRTOS 中,这被称为Tickless Idle Mode,参见 https://www.freertos.org/low-power-tickless-rtos.html

Note: If eTaskConfirmSleepModeStatus() returns eNoTasksWaitingTimeout when it is called from within portSUPPRESS_TICKS_AND_SLEEP() then the microcontroller can remain in a deep sleep state indefinitely. eTaskConfirmSleepModeStatus() will only return eNoTasksWaitingTimeout when the following conditions are true:

  1. Software timers are not being used, so the scheduler is not due to execute a timer callback function at any time in the future.

  2. All the application tasks are either in the Suspended state, or in the Blocked state with an infinite timeout (a timeout value of portMAX_DELAY), so the scheduler is not due to transition a task out of the Blocked state at any fixed time in the future.

To avoid race conditions the RTOS scheduler is suspended before portSUPPRESS_TICKS_AND_SLEEP() is called, and resumed when portSUPPRESS_TICKS_AND_SLEEP() completes. This ensures application tasks cannot execute between the microcontroller exiting its low power state and portSUPPRESS_TICKS_AND_SLEEP() completing its execution. Further, it is necessary for the portSUPPRESS_TICKS_AND_SLEEP() function to create a small critical section between the tick source being stopped and the microcontroller entering the sleep state. eTaskConfirmSleepModeStatus() should be called from this critical section.

All GCC, IAR and Keil ARM Cortex-M3 and ARM Cortex-M4 ports now provide a default portSUPPRESS_TICKS_AND_SLEEP() implementation. Important information on using the ARM Cortex-M implementation is provided on the Low Power Features For ARM Cortex-M MCUs page.

因此在 freeRTOS 中调用无滴答空闲模式相当于深度 sleep 或断电。可能你必须手动禁用皮质上的内部计时器......

在 Contiki OS 中关闭 ATmega128RFA1 MCU 时遇到一些问题...

关于c - 嵌入式RTOS停止系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48345800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com