Low Power Mode and Power measurement

This tutorial provides introduction to Low Power modes of MT7687/MT7697. Topics about the operating mechanism, hardware setup for the measurement, and measurement steps will be guided through the following sections.

Operating mechanism

Concept

With LinkIt SDK 4.3, MT7687/MT7697 support four low power modes which exhibit different levels of power consumption. Developers can choose a proper power mode for saving power according to different application scenarios. These modes are: Idle mode, Sleep mode (a.k.a. WFI [Wait For Interrupt] mode), Legacy Sleep mode, and RTC mode. Under different modes, the corresponding states of each functional block in the system are listed in the table below:

Power Mode CPU Clock CM4 bus clock PLL RAM Power Consumption Wake-up Source
Idle Gated On On Active Moderate SW interrupt / Peripheral / EINT / GPT
Sleep (WFI) Gated On Off Active Low Peripheral / EINT / GPT
Legacy Sleep Gated Gated Off Sleep Lower EINT / GPT
RTC Powered Off Powered Off Off Powered Off Lowest -
  • Idle: Only the CM4 CPU is suspended. Other system blocks remain in the original operation states.
  • Sleep (WFI): The CM4 CPU is suspended and system clock is set lowered. The program counter and the data in RAM are retained. The MCU can be waken up by ordinary interrupts from peripherals, like UART, I2C, SPI... etc., and continue to execute instructions as it didn't go to sleep. 
  • Legacy Sleep: As in the WFI mode, the system states are retained. However, since it sleeps deeper, ordinary peripherals are turned off so that they cannot be used to wake up the system. In order to exit the sleep mode, an interrupt from EINT is needed while the MCU is in the Legacy Sleep mode.
  • RTC: The MCU system is totally powered off and thus all volatile data is gone. In this mode, only the RTC module is powered on and keeps the timer running. When the sleep timer expires, the RTC module will issue an interrupt which can be used to power on and boot up the MCU.

The power consumption data of MT7687/MT7697 is listed below. It can also be found in the datasheet inside the /doc folder of the LinkIt SDK (Table 4-8 Current Consumption in Different Scenarios).

Scenario Typical Results (mA)
Legacy Sleep 0.667
RTC mode 0.0031
Wi-Fi Radio Off (WFI mode, tickless) 10.79
Wi-Fi Radio Off (Legacy Sleep, tickless) 0.97
Wi-Fi Connected (WFI, DTIM1, tickless) 14.18
Wi-Fi Connected (Legacy Sleep, DTIM 1, tickless) 4.64
Wi-Fi Connected (Legacy Sleep, DTIM 10, tickless) 2.07

Note: The measurement results may be varying with different SDK versions, Wi-Fi quality in the field, temperature, and different production batches of HDKs. For most of the case, the reasonable variance is within ±15%.

Software APIs

Developers can use Sleep Manager HAL APIs to control the Idle, Sleep (WFI), and Legacy Sleep power mode. A HAL example under $SDK_ROOT/project/mt7687_hdk/hal_examples/sleep_manager_power_mode demonstrates the API usage. As for controlling the RTC mode, another set of APIs in the RTC module are needed.

hal_sleep_manager.h - The enum for different power modes
typedef enum {
    HAL_SLEEP_MODE_NONE = 0,        /**< no sleep */
    HAL_SLEEP_MODE_IDLE,            /**< idle state */
    HAL_SLEEP_MODE_SLEEP,           /**< wfi sleep state */
    HAL_SLEEP_MODE_LEGACY_SLEEP,    /**< legacy sleep state */
    HAL_SLEEP_MODE_NUMBER           /**< for support range detection */
} hal_sleep_mode_t;

Tickless Mode

Tickless mode is a mode defined by FreeRTOS to stop the periodic tick interrupt during idle periods (periods when there are no application tasks that are able to be executed, i.e. only the idle_task is running), and then make correct adjustments to the RTOS tick count value when the tick interrupt is restarted. To enable the tickless mode, you need to edit the FreeRTOSConfig.h header file in the example project folder and set configUSE_TICKLESS_IDLE to 2.

#define configUSE_TICKLESS_IDLE    2

Three values are supported for this definition: 

  • 0 for disabled,
  • 1 for FreeRTOS default implementation (not used in LinkIt SDK), and 
  • 2 for vendor specific implementation.

Note: When using a debugger to debug the system, remember to turn off the tickless mode first (set configUSE_TICKLESS_IDLE to 0) to prevent it from entering the sleep mode.

In LinkIt SDK, you can set this value to 2 for enabling the tickless mode implementation. The tickless implementation is illustrated as the following figure:

When there is no other task to be executed, the idle task will be invoked and it further triggers the tickless mode operation. In the default LinkIt SDK implementation (under $SDK_ROOT/kernel/rtos/FreeRTOS/Source/portable/GCC/mt7687/port_tick.c), it first examines how much time this sleep duration will be. If it's longer than 10ms, the system will go into the Sleep (WFI) mode. Otherwise, considering to the overhead of entering/exiting the Sleep (WFI) mode, the Idle mode will be selected, by calling APIs from the Sleep Manager.

RTC Module

RTC is a module within MT7687/MT7697 with a standalone power source (powered by pin RTC_3V3 of the chip) so that it can remain powered on while other parts of MT7687/MT7697 MCU core (PMU and RF) are powered off. Because it only needs few currents for its operation, the most power-efficient case would be MCU is powered off when it doesn't do anything and only keeps RTC alive. And later when the sleep timer in the RTC expires, the RTC will trigger an interrupt and this interrupt can be used to power on the MCU to make the system boot up and start to work. After the work is done, the MCU is powered off again (and the RTC is still alive) and waits for the next wake up event through the interrupt from the RTC module. 

In the real PCB design, you need to use an external circuit (e.g. a switch) controlled by the RTC interrupt signal (PMU_EN_RTC) for bridging the power source to the MCU core and eliminating the leakage current when the MCU core is turned off.

MT7687 power block diagram 

Hardware Setup

A LinkIt 7687 HDK would be used as an example to demonstrate how to setup the environment for measuring power consumption. Nevertheless, this can also be applied to other MT7687/MT7697 HDKs or modules with the same concept.

Bypass MK20 Power Consumption

MK20, which is served as a USB2UART bridge chip in this case, is used to issue commands for entering different power modes and to check system logs from the serial output. This is needed for performing measurements. However, when measuring the power consumption of MT7687, you need to exclude the MK20 operating currents. 

The LinkIt 7687 HDK can be powered on by one of two sources: one is from the USB 5V input and the other is from the 2xAA input header (i.e. for 2 AA batteries). Power from USB 5V will be converted to 3.3V for powering both MK20 and MT7687. On the other hand, power from 2xAA header will simply be sent to MT7687, without supplying to MK20. As a result, you need to break the power path from USB 5V to MT7687 to make it only supply to MK20, not further to MT7687. This makes the MK20 alive (for us to issue testing commands) and not affect the measurement of currents fed to MT7687.

To break the power path from USB 5V, two jumpers (J23 / J27) need to be removed as the figure above. Let's get a closer look into the schematics for this.

Power from USB 5V will be level-shifted to 3.3V, which is marked as DC_DC_3V3 as above. And it will be treated as the 3V3_IN and the VRTC_IN used by the MT7687 core and the RTC module respectively. By disconnecting J27 and J23 jumpers, power from USB 5V will not go into the MT7687 core and the RTC module.

Powering the Board without going through a Buck-Boost Converter

From the previous step, we've disconnected the 3.3V power from USB to make it not go into MT7687 (neither for core nor for RTC). Next, you need to feed power into the board to boot up MT7687. However, this cannot simply be done by providing power directly into the 2xAA header. This is because the power fed to the 2xAA header will go through a buck-boost converter for making the voltage of 2xAA batteries become 3.3V, which is required by MT7687 core* (marked as V_2AA_O_3V3 in the figure below). This introduces additional power consumption in the measurement so you'll want to get rid of it.

*Note: Since the working voltage range of the RTC module is between 1.6V ~ 3.63V, the RTC module can be powered on from the 2xAA header directly (marked as  V_2AA_B_I in the figure below) without level-shifting. You can also check this from the schematics listed above: the "RTC Domain Power Measurement" part.

where V_2AA_B_I and V_2AA_O_3V3 are

As a consequence, J30 and J26 need to be removed and provide 3.3V power source directly to the #2 pins of headers under the jumpers. They are marked as green in the following schematics and picture. 

 

Finally, putting all materials mentioned above, the summary of the configuration is:

  • Remove J27 and J23 to make USB 5V only provide to MK20.
  • Remove J30 and J26 to reveal the power input header pins.
  • Connect the USB port with PC to provide power to MK20 for accessing the system console.
  • Connect 3.3V power source to #2 pins of headers under J30 and J26.
  • Connect the GND source to the V- pin of the 2xAA header.

The resulting connection is:

Instruments for Measuring Power Consumption

Here two types of instruments which can be used to measure the power consumption are introduced: 1) a Power Monitor, or 2) a Multimeter.

Using a Power Monitor

For more precise and rich informative measurement results, you can use a solution like Power Monitor from Monsoon Solution. It works as the power supply for the HDK but also can monitor the current consumption with timing information. By connecting it with the LinkIt 7687 HDK as below, you can get the time-variant information for the power consumption.

This is an example for the measurement results. The current consumption data can be visualized as a graph with timing information (X-axis: time stamps during the measurement process; Y-axis: current value in mA).

Using a Multimeter

For ease of use and a more cost-effective choice, a multimeter can be used as the instrument for performing the measurement. Although it cannot show the data with timing information and is less precise, it can still give a good idea about how the instant current consumption is. A multimeter can be connected to the LinkIt 7687 HDK as below for doing the measurement:

Note: Make sure the selection knob is moved to the current measurement mode. Moreover, it's suggested to put the knob in the 200mA position for measurement before the HDK goes into any low power mode.

Software Setup

iot_sdk Example Project

With the SLA-versioned LinkIt SDK, there is an example project named iot_sdk under the /project/mt7687_hdk/apps folder*. It consists of many CLI commands to demonstrate different features of MT7687/MT7697. When booting up the HDK with iot_sdk as the CPU firmware, typing a '?' (and press the enter key) in the command line of the MT7687/MT7697 console will show all supported commands:

$
$ ?
en     - enter test mode
fota   - storage mgmt
ip     - ip config
ping   - ping <addr> <count> <pkt_len>
iperf  - iperf
config - user config read/write/reset/show
smart  - smart connection
wifi   - wifi api
log    - log control
gpio_cli - gpio get and set
reboot   - reboot
ver      - f/w ver
os       - os info
$
You'll use those commands to setup the environment and go to different power modes to measure the power consumption mentioned in the beginning of this tutorial.

*Note: For public SDK users, you can download the pre-built bin files of the  iot_sdk example project here:  for LinkIt 7687 HDK or  for MT7697 HDK (SDK 4.3).

Wi-Fi Configuration

In some of the testing scenarios mentioned above, you need to establish a Wi-Fi connection before doing the measurement. So here we introduce how to make the HDK connect to an existing wireless network. Assume the information of the Wi-Fi AP is:

  • SSID: Test_AP
  • Password: 12345678

You can use the following commands to setup the HDK to connect to this AP. It is a one-time setup and the configurations will be stored in the flash storage. Once it's done, the HDK will connect to this AP every time it boots up.

$ config write STA Ssid Test_AP 
$ config write STA SsidLen 7 
$ config write STA AuthMode 7
$ config write STA EncrypType 6
$ config write STA WpaPsk 12345678
$ config write STA WpaPskLen 8
$ config write STA PSMode 2

Note: Both SsidLen and WpaPskLen fields need to match the exact string lengths of the SSID and the password. Make sure to set them in correct values for your Wi-Fi environment.

After the configuration is done, reboot the HDK and when it successfully connects to the AP, you'll see message like below:

[T: 7978 M: common C: INFO F: wifi_station_port_secure_event_handler L: 124]: wifi connected
[T: 8919 M: common C: INFO F: ip_ready_callback L: 75]: ************************
[T: 8919 M: common C: INFO F: ip_ready_callback L: 76]: DHCP got IP:192.168.100.109
[T: 8919 M: common C: INFO F: ip_ready_callback L: 77]: ************************

You can also use the ping command to check the connection. The following example shows a successful ping operation (which pings to 8.8.8.8) for three times with a 64-byte packet size:

$ ping 8.8.8.8 3 64
[T: 344958 M: ping C: INFO F: ping_recv L: 254]: [ping]: ping: recv seq(0x0001) 8.8.8.8, 10 ms
[T: 345965 M: ping C: INFO F: ping_send L: 192]: [ping]: ping: send seq(0x0002) 8.8.8.8
[T: 345976 M: ping C: INFO F: ping_recv L: 254]: [ping]: ping: recv seq(0x0002) 8.8.8.8, 3 ms
[T: 346983 M: ping C: INFO F: ping_send L: 192]: [ping]: ping: send seq(0x0003) 8.8.8.8
[T: 346998 M: ping C: INFO F: ping_recv L: 254]: [ping]: ping: recv seq(0x0003) 8.8.8.8, 7 ms
[T: 348005 M: ping C: INFO F: ping_thread L: 376]: [ping]: 8.8.8.8, Packets: Sent = 3, Received =3, Lost = 0 (0% loss)
[T: 348005 M: ping C: INFO F: ping_thread L: 377]: [ping]:  Packets: min = 3, max =10, avg = 6

Commands for Entering Different Power Scenarios

The following table gives all commands needed for performing measurements with different power mode scenarios using the iot_sdk example project:

 

Scenario Commands Descriptions Typical Results (mA)
Legacy Sleep

$ wifi config set radio 0

$ en

$ lp ls 300

  1. Turn off the Wi-Fi radio
  2. Enter the Test mode
  3. Go to Legacy Sleep mode and wake up after 300 seconds
0.667
RTC mode[1]

$ wifi config set radio 0

$ en

$ lp rtc

  1. Turn off the Wi-Fi radio
  2. Enter the Test mode
  3. Go to RTC mode
0.0031
Wi-Fi Radio Off (WFI mode, tickless[2])

$ wifi config set radio 0

$ en

$ lp tick 1

  1. Turn off the Wi-Fi radio
  2. Enter the Test mode
  3. Turn on the tickless mode with Sleep (WFI) enabled
    Note: the parameter "1" means Sleep (WFI) power mode
10.79
Wi-Fi Radio Off (Legacy Sleep, tickless)

$ wifi config set radio 0

$ en

$ lp tick 2

  1. Turn off the Wi-Fi radio
  2. Enter the Test mode
  3. Turn on the tickless mode with Legacy Sleep enabled
    Note: the parameter "2" means Legacy Sleep power mode
0.97
Wi-Fi Connected (WFI, DTIM1, tickless)

$ wifi config set listen 1

$ en

$ lp tick 1

Before running this test, make sure the Wi-Fi connection is established.

  1. Set the Wi-Fi listen interval[3] to 100ms
  2. Enter the Test mode
  3. Turn on the tickless mode with Sleep (WFI) enabled
    Note: the parameter "1" means Sleep (WFI) power mode
14.18
Wi-Fi Connected (Legacy Sleep, DTIM 1, tickless)

$ wifi config set listen 1

$ en

$ lp tick 2

Before running this test, make sure the Wi-Fi connection is established.

  1. Set the Wi-Fi listen interval to 100ms
  2. Enter the Test mode
  3. Turn on the tickless mode with Legacy Sleep enabled
    Note: the parameter "2" means Legacy Sleep power mode
4.64
Wi-Fi Connected (Legacy Sleep, DTIM 10, tickless)

$ wifi config set listen 10

$ en

$ lp tick 2

Before running this test, make sure the Wi-Fi connection is established.

  1. Set the Wi-Fi listen interval[4] to 1,000ms
  2. Enter the Test mode
  3. Turn on the tickless mode with Legacy Sleep enabled
    Note: the parameter "2" means Legacy Sleep power mode
2.07

Note 1After entering the RTC mode, the wire on pin #2 of J30 needs to be disconnected to eliminate the current leakage on MCU core and to get the exact current consumed by the RTC module only.

Note 2For scenarios with tickless mode enabled, the device will go into low power state only when  the idle task is running . Therefore, after issuing testing commands, leave the device alone without further entering commands or connecting to other peripherals. After seconds, you should be able to see the measured current consumption dropped.

Note 3: Since DTIM is used to describe the configuration in the AP side, which usually is not adjustable, similar network traffic can be simulated by adjusting the listen interval in the client device side. 

Note 4For LinkIt SDK 4.3, there is an issue preventing the system from going into listen interval 10. This will be fixed in the next SDK release.

Note 5: These commands are used to enter corresponding low power scenarios, not for other system functionalities. Therefore it doesn't guarantee the system behavior after waking up from sleep with these commands. Remember to reboot the device every time a different test is going to be proceeded.