Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the AliOS Things Power Management Framework

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use the AliOS Things power management framework", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use the AliOS Things power management framework"!

A brief introduction to the power management framework

The purpose of the power management framework is to save the power consumption of CPU. Traditionally, idle task is executed when the operating system is idle, such as when all user tasks and system tasks are blocked. The usual practice of idle task is a while (1) empty loop, which, from an assembly point of view, keeps executing jump instructions, that is, when the operating system is idle, CPU will be idle. After the enable power management framework, when the system enters the idle task, the CPU will be set to enter the low-power state, thus saving the power consumption of the CPU.

Cdn.com/96a5ec7cc6a37077316a02632ad479e7cf228220.png ">

The AliOS Things power management framework has the following characteristics:

(1) after applying the configuration power management framework and adding the initialization code, the operation of the whole framework is transparent to the application, and users do not need to modify the application code in order to support the power management framework.

(2) support multi-level low power state

On some MCU, it is divided into multi-level sleep according to different power saving and wake-up time. The power management framework provides support for this feature. When entering the low-power state, the best sleep level will be selected according to sleep time and power saving.

(3) support tickless mechanism

When the MCU decides to enter the low power state, the system tick interrupt will be turned off, and the system tick interruption will be restored when waking up and the number of tick lost during sleep will be compensated. This strategy minimizes the power consumption when the system is idle by reducing the system clock interruption.

(4) support simplified and low power consumption mode

When the MCU enters the low power consumption, the system tick can wake up the system without shutting down the system tick interrupt. Its advantage is that it is easy to implement, but when the system is idle for a long time, the system clock wakes up the system frequently, which is not conducive to energy saving.

Test the performance of the power management framework on a nrf52832 MCU-based development board as follows:

In the normal operating mode, the average operating current of nrf52832 MCU is about 4mA. After adding the power management module, the current test of MCU is shown in the following table:

Test item

Average current

Description

Low power state

2.06uA

BLE broadcast power consumption (turn on low power module, broadcast intervel 100ms)

120uA

Voltage 3v, transmission load 21 bytes, TX power 0dBm.

BLE broadcast power consumption (turn on low power module, broadcast intervel 1000ms)

14.7uA

Voltage 3v, transmission load 21 bytes, TX power 0dBm.

BLE broadcast power consumption (turn on low power module, broadcast intervel 2000ms)

8.1uA

Voltage 3v, transmission load 21 bytes, TX power 0dBm.

From the test results, it can be seen that it is necessary to use the power management framework for power sensitive systems, such as battery-powered systems, which can significantly reduce system power consumption and increase system standby time.

2. Application configuration (adding low-power support for applications)

To use the power management framework for an application, the following configuration is required:

(1) add dependence on power management module to the .mk file of the application directory, for example:

GLOBAL_DEFINES + = RHINO_CONFIG_CPU_PWR_MGMT=1

$(NAME) _ COMPONENTS: = rhino/pwrmgmt

(2) call the power management module initialization function in the application initialization function (such as application_start (int argc, char * argv [])).

Cpu_pwrmgmt_init ()

3. Sample application (app/example/pwr_test)

At present, AliOS Things 2.0 adapts the power management framework on developerkit and PCA10040 platforms. You can compile the sample application and download it to develoerkit to run with the following command:

Aos make pwr_test@developerkit

Aos upload pwr_test@developerkit

The example application creates two tasks, demo1 and demo2. The main logic of demo1 is a while loop: count1 increases by 1, prints the values of count1 and g_idle_count [0] at the same time, and then sleeps for 1 second. The main logic of demo2 is also a while loop: count2 increases by 1, prints the value of count2, and then sleeps for 2 seconds.

Where g_idle_count [0] is a global variable that the idle task accumulates when it is executed.

If the low power module is not turned on, the idle task continues to execute and the g_idle_count [0] increases continuously when the demo1 and demo2 are asleep. An example of output is as follows:

Count1 = 0, idle = 0

Count2 = 0

Count1 = 1, idle = 2347298

Count1 = 2, idle = 4693421

Count2 = 1

Count1 = 3, idle = 7036926

Count1 = 4, idle = 9383049

Count2 = 2

Count1 = 5, idle = 11726554

Count1 = 6, idle = 14072465

When low power consumption is turned on, when demo1 and demo2 are in sleep state, the idle task execution g_idle_count [0] increases by 1, and cpu_pwr_down () is called to enter the low power state. Therefore, each time the system enters the idle state, the g_idle_count [0] only increases by 1. An example of output is as follows:

Count1 = 0, idle = 0

Count2 = 0

Count1 = 1, idle = 1

Count2 = 1

Count1 = 2, idle = 3

Count1 = 3, idle = 4

Count2 = 2

Count1 = 4, idle = 6

Count1 = 5, idle = 7

Description: if conditions permit, directly test the power consumption, such as testing the current of the MCU, the effect is more intuitive.

IV. Adaptation of power management framework

Because the operation of the power management framework depends on the hardware capability, we should first analyze whether the target hardware has the ability to support it, and then provide the relevant drivers for the power management framework based on the hardware capability.

4.1 hardware requirements

To support the power management framework, the target MCU needs to support the following features:

(1) at least one low power mode is supported. In this low power mode, the values of RAM and registers can be maintained.

(2) in low power mode, there is an available timer, and the timer can wake up the system. Under the tickless mechanism, the timer is used to calculate the low power consumption time to compensate the system clock.

4.2 Adaptive Interface

In order to support the power management module, the following interface adaptations need to be completed:

Adaptive interface

Function description

Board_cpu_pwr_init

Initialize CPU power management capabilities, such as registering CPU power state setting functions, registering CPU power management capabilities, registering wake-up delay time, registering wake-up / timing timers.

Cpu_cstate_set_t

Set the low power state of CPU

Systick_suspend

Suspend the system clock, and the system clock stops running at low power consumption

Systick_resume

Restore the system clock

One_shot_timer_t

Wake-up / timing timer running at low power consumption. Timing at low power consumption is used to compensate the system clock when exiting the low power state.

During the adaptation process, users can call the following APIs:

Available interface

Functional Overview

Cpu_pwr_node_init_static

Initialize the CPU node

Cpu_pwr_node_record

Register the CPU node

Cpu_pwr_c_state_capability_set

Set the low power mode supported by CPU

Cpu_pwr_c_state_latency_save

Set the wake-up delay time for a specified low-power state

Tickless_one_shot_timer_save

Register timers that support the tickless mechanism

Cpu_pwr_c_method_set

Register the CPU status setting function

Thank you for reading, the above is the content of "how to use the AliOS Things power management framework". After the study of this article, I believe you have a deeper understanding of how to use the AliOS Things power management framework, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report