Power Manager
1 Overview
Demonstrates the platform power manager features, including normal sleep, low-voltage sleep, and deep sleep.
2 Code Path
Demo path: components\bk_cli\cli_pwr.c
3 CLI Command Reference
The demo depends on the following configuration:
NAME |
Description |
File |
value |
|---|---|---|---|
CONFIG_MCU_PS |
enable low-power support |
|
y |
Supported CLI commands:
Command group 1
pm [sleep_mode] [wake_source] [vote1] [vote2] [vote3] [param1] [param2] [param3]
sleep_mode: sleep mode (0-3)
0: normal sleep
1: low voltage
2: deep sleep
3: none
wake_source: wakeup source (0-5)
0: GPIO
1: RTC
2: Wi-Fi / BT
3: USB (not supported on BK72xx, available on other products)
4: Touch
5: none
vote1 / vote2 / vote3: vote values (8: BT, 9: Wi-Fi, 12: APP)
param1: depends on the wake source
- GPIO: GPIO ID
- RTC: wakeup time (ms)
- Wi-Fi / BT: reserved
- Touch: touch channel ID
param2: depends on the wake source
- GPIO: wakeup trigger (0: low level, 1: high level, 2: rising edge, 3: falling edge)
- RTC / Touch: not used (set to 0)
param3: BT sleep time (compatibility parameter). Recommended value: 1000000000 (100 s) so that the BT module uses its internal setting.
Example 1 – Use GPIO to wake the device from deep sleep
Test steps:
1) Wait ~5 seconds after power-up (BT, Wi-Fi, CPU initialization completes).
2) Execute:
A. pm 2 0 8 9 12 9 0 1000000000 (enter deep sleep; GPIO acts as the wake source; GPIO ID = 9; low-level wake).
B. For high-level wakeup: set the initial GPIO level low, then pull it high to wake.
C. For low-level wakeup: set the initial GPIO level high, then pull it low to wake.
D. For rising-edge wakeup: start low, then pull high to wake.
E. For falling-edge wakeup: start high, then pull low to wake.
3) During deep sleep, VDDDIG drops to 0 V; after wakeup it returns to ~1.1 V.
4) Measure power consumption throughout the deep sleep → wake cycle with a precision supply.
Expected results:
1) VDDDIG is ~0 V during deep sleep and ~1.1 V after wakeup.
2) Power consumption from deep sleep to wake matches measurements from the precision supply.
3) Deep sleep current meets the 15–20 µA target.
Example 2 – Use RTC to wake the device from deep sleep
Test steps:
1) Wait ~5 seconds after power-up.
2) Run: pm 2 1 8 9 12 3000 0 1000000000 (enter deep sleep; RTC wake; wake time = 3000 ms).
3) The system wakes when the configured time expires.
4) During deep sleep, VDDDIG drops to 0 V; after wakeup it returns to ~0.875 V (or ~0.925 V if the clock is boosted).
5) Measure power consumption during the deep sleep cycle.
Expected results:
1) VDDDIG is ~0 V during deep sleep and ~0.875 V (or ~0.925 V when boosted) after wakeup.
2) Power consumption matches measurements from the precision supply.
3) Deep sleep current is approximately 15–20 µA.
Example 3 – Use Touch to wake the device from deep sleep
Test steps:
1) Wait ~5 seconds after power-up.
2) Execute:
A. touch_single_channel_calib_mode_test 2 1 (channel = 2 by default; strength = 1, range 0–3).
B. pm 2 4 8 9 12 2 0 1000000000 (enter deep sleep; wake with touch).
C. Touch the sensor to wake the system.
3) During deep sleep, VDDDIG ≈ 0 V; after wake, VDDDIG ≈ 0.875 V (higher if boosted).
4) Measure power consumption through the cycle.
Expected results:
1) VDDDIG ≈ 0 V during deep sleep; ≈ 0.875 V after touch wake (≈ 0.925 V when boosted).
2) Power consumption matches precision measurements.
3) Deep sleep current ≈ 15–20 µA.
Example 4 – Use GPIO to wake the device from low-voltage sleep
Test steps:
1) Wait ~5 seconds after power-up.
2) Execute:
A0. For optimum power, disable BT when not needed (`AT+BLEPOWER=0`).
A. pm 1 0 8 9 12 9 2 1000000000 (enter low voltage; GPIO wake; GPIO ID = 9; rising-edge wake).
B. High-level wake: start low, then drive high.
C. Low-level wake: start high, then drive low.
D. Rising-edge: start low, drive high.
E. Falling-edge: start high, drive low.
3) In low voltage, VDDDIG = configured voltage (e.g. 0.6 V); after wake, VDDDIG ≈ 1.1 V.
4) Measure power consumption over the cycle.
Expected results:
1) VDDDIG ~0.6 V during low voltage, ~0.875–0.925 V after wake.
2) Power consumption matches precision measurements.
Example 5 – Use RTC to wake the device from low-voltage sleep
Test steps:
1) Wait ~5 seconds after power-up.
2) Execute:
A. Wi-Fi enters sleep when idle.
B. BT defaults to sleep (turn off with `AT+BLEPOWER=0` when done).
C. pm 1 1 0 0 12 10000 0 1 (enter low voltage; RTC wake; wake time = 10000 ms).
3) The system wakes when the specified time elapses.
4) In low voltage, VDDDIG ≈ configured voltage (e.g. 0.6 V); after wake, VDDDIG ≈ 0.875 V (0.925 V when boosted).
5) Measure power consumption during the entire cycle.
Expected results:
1) VDDDIG ≈ 0.6 V during low voltage and ≈ 0.875–0.925 V after wake.
2) Power consumption matches precision measurements.
Example 6 – Use Touch to wake the device from low-voltage sleep
Test steps:
1) Wait ~5 seconds after power-up.
2) Execute:
A0. Disable BT after use (`AT+BLEPOWER=0`) for optimal power.
A. touch_single_channel_calib_mode_test 2 1 (channel 2 by default; strength 0–3).
B. pm 1 4 8 9 12 2 0 1000000000 (enter low voltage; touch wake; channel = 2).
C. Touch the sensor to wake the system.
3) In low voltage, VDDDIG ≈ 0.6 V; after wake, VDDDIG ≈ 0.875 V (≈ 0.925 V when boosted).
4) Measure power consumption during the cycle.
Expected results:
1) VDDDIG ≈ 0.6 V during low voltage and ≈ 0.875–0.925 V after wake.
2) Power consumption matches precision measurements.
Command group 2
pm_vote [sleep_mode] [pm_vote] [pm_vote_value] [pm_sleep_time]
sleep_mode: 0 = normal, 1 = low voltage, 2 = deep sleep, 3 = none
pm_vote: vote owner (8: BT, 9: Wi-Fi, 12: APP)
pm_vote_value: 0 = MODULE_STATE_ON, 1 = MODULE_STATE_OFF
pm_sleep_time: BT sleep duration (compatibility parameter). Recommended value: 1000000000 so the BT module uses its internal timer.
Example 1 – Wake from low-voltage sleep while keeping Wi-Fi alive
Test steps:
1) Wait ~5 seconds after power-up.
2) Execute:
A. set_interval 10 (configure DTIM 10; use 1 or 3 for DTIM1/3).
B. sta <ssid> <password> (connect to AP; Wi-Fi enters sleep/wake cycle).
C. Disable BT when idle (`AT+BLEPOWER=0`).
D. pm_vote 1 12 1 0 (cast the APP vote).
3) In low voltage, VDDDIG ≈ 0.6 V; after wake, VDDDIG ≈ 0.875–0.925 V.
4) Measure power consumption throughout the cycle.
Note
Difference between pm_vote and pm:
pm_voteonly casts the vote to enter low voltage; it does not configure wake sources. Typical usage is when another module (e.g. Wi-Fi) already configures its wakeup path.pmboth casts the vote and configures wake sources such as RTC, GPIO, or Touch.