|
| 1 | +.. _power_consumption_sample: |
| 2 | + |
| 3 | +.. ncs-sample:: |
| 4 | + :title: Power consumption (System ON Idle) |
| 5 | + |
| 6 | + The Power consumption (System ON Idle) sample demonstrates how to evaluate the power consumption of the nRF7120 SoC during the System ON Idle state. |
| 7 | + The sample application is set to periodically sleep for a configurable duration, after which the device wakes up from sleep, printing the wake up count. |
| 8 | + In addition to that, the sample demonstrates the different RAM retention levels available through the :ref:`lib_ram_pwrdn` library. |
| 9 | + |
| 10 | +Requirements |
| 11 | +************ |
| 12 | + |
| 13 | +The sample supports the following development kit: |
| 14 | + |
| 15 | +.. table-from-sample-yaml:: |
| 16 | + |
| 17 | +The sample also requires a `Power Profiler Kit II (PPK2)`_, for measuring current consumption. |
| 18 | + |
| 19 | +Overview |
| 20 | +******** |
| 21 | + |
| 22 | +At boot, the sample performs the following operations: |
| 23 | + |
| 24 | +1. Prints a reminder to switch the board's power off and back on before taking a power measurement (see `Measuring the power consumption`_). |
| 25 | +#. Applies the user-configured RAM retention level. |
| 26 | +#. Enters a periodic loop, where it: |
| 27 | + |
| 28 | + a. Transits to sleep (System ON Idle) for a period of :kconfig:option:`CONFIG_SAMPLE_POWER_CONSUMPTION_IDLE_SECONDS` (10 seconds by default). |
| 29 | + #. Wakes up from sleep. |
| 30 | + #. Prints the wake-up counter value. |
| 31 | + #. Transits to sleep again. |
| 32 | + |
| 33 | +RAM retention levels |
| 34 | +===================== |
| 35 | + |
| 36 | +By default, all application RAM is retained during System ON Idle. |
| 37 | +The sample's own Kconfig allows the user to configure the amount of RAM that is retained, exposing a choice of retention levels, each backed by the :ref:`lib_ram_pwrdn` library: |
| 38 | + |
| 39 | +.. list-table:: |
| 40 | + :header-rows: 1 |
| 41 | + |
| 42 | + * - Kconfig option |
| 43 | + - Behavior |
| 44 | + * - :kconfig:option:`CONFIG_SAMPLE_POWER_CONSUMPTION_RAM_RETAIN_FULL` (default) |
| 45 | + - All RAM stays retained. |
| 46 | + No RAM is powered down. |
| 47 | + * - :kconfig:option:`CONFIG_SAMPLE_POWER_CONSUMPTION_RAM_RETAIN_64K` |
| 48 | + - Only the first 64 KiB of RAM stays retained; the rest is powered down. |
| 49 | + * - :kconfig:option:`CONFIG_SAMPLE_POWER_CONSUMPTION_RAM_RETAIN_128K` |
| 50 | + - Only the first 128 KiB of RAM stays retained; the rest is powered down. |
| 51 | + * - :kconfig:option:`CONFIG_SAMPLE_POWER_CONSUMPTION_RAM_RETAIN_256K` |
| 52 | + - Only the first 256 KiB of RAM stays retained; the rest is powered down. |
| 53 | + * - :kconfig:option:`CONFIG_SAMPLE_POWER_CONSUMPTION_RAM_RETAIN_512K` |
| 54 | + - Only the first 512 KiB of RAM stays retained; the rest is powered down. |
| 55 | + * - :kconfig:option:`CONFIG_SAMPLE_POWER_CONSUMPTION_RAM_RETAIN_UNUSED_ONLY` |
| 56 | + - Powers down all RAM that is left unused by the sample application image, using the library's own automatic detection (``power_down_unused_ram()``), instead of a fixed KiB boundary. |
| 57 | + |
| 58 | +Building and running |
| 59 | +******************** |
| 60 | + |
| 61 | +.. |sample path| replace:: :file:`nrf/samples/benchmarks/power_consumption` |
| 62 | + |
| 63 | +.. include:: /includes/build_and_run.txt |
| 64 | + |
| 65 | +The default configuration (all RAM retained) is built with: |
| 66 | + |
| 67 | +.. code-block:: console |
| 68 | +
|
| 69 | + west build -p always -b nrf7120dk/nrf7120/cpuapp nrf/samples/benchmarks/power_consumption |
| 70 | +
|
| 71 | +To build the sample with any other of the supported RAM retention levels, pass the matching Kconfig option on the command line, for example: |
| 72 | + |
| 73 | +.. code-block:: console |
| 74 | +
|
| 75 | + west build -p always -b nrf7120dk/nrf7120/cpuapp nrf/samples/benchmarks/power_consumption -- -DCONFIG_SAMPLE_POWER_CONSUMPTION_RAM_RETAIN_64K=y |
| 76 | +
|
| 77 | +The same supported six configurations are also given in the :file:`tests.yaml` file (for example ``sample.benchmarks.power_consumption.ram_retain_64k``), for use with ``west build -T <name>`` or Twister. |
| 78 | + |
| 79 | +Testing |
| 80 | +======== |
| 81 | + |
| 82 | +|test_sample| |
| 83 | + |
| 84 | +Measuring the power consumption |
| 85 | +------------------------------- |
| 86 | + |
| 87 | +.. important:: |
| 88 | + The debugger or SWD connection used during flashing draws additional current and can leave the target in a state that does not reflect its true standalone power consumption. |
| 89 | + Always power-cycle the target after flashing before taking a reading, as described in **Step 8** below. |
| 90 | + |
| 91 | +**P601** is a 1x3 header (pin 1 ``P5V0``, pin 2 ``VBAT_5V0``, pin 3 ``GND``), normally bridged by the **JP601** shunt jumper so ``P5V0`` feeds straight through to ``VBAT_5V0``. |
| 92 | +To measure current with a PPK2 in source meter mode, complete the following steps: |
| 93 | + |
| 94 | +1. Remove the **JP601** shunt jumper from **P601**. |
| 95 | +#. Connect the PPK2's **Vout** to **P601** pin 2 (``VBAT_5V0``). |
| 96 | +#. Connect the PPK2's **GND** to **P601** pin 3 (``GND``). |
| 97 | +#. Connect the USB cable to the DK to flash the image (the DK's interface MCU/debugger runs on its own USB-derived supply; with the **JP601** shunt removed, the nRF7120 itself is powered only from **P601** pin 2, i.e. the PPK2, throughout). |
| 98 | +#. In the PPK2 app, select **Source Meter** mode and enable power output with **3.6 V** as the supply voltage. |
| 99 | +#. Run ``west flash`` to flash the image. |
| 100 | +#. Remove the USB cable. |
| 101 | +#. Toggle the PPK2's **Enable power output** control off and back on. |
| 102 | + This power-cycles the target now that the debugger is disconnected, giving an accurate measurement. |
| 103 | + |
| 104 | +Sample output |
| 105 | +************** |
| 106 | + |
| 107 | +The sample shows the following output: |
| 108 | + |
| 109 | +.. code-block:: console |
| 110 | +
|
| 111 | + Power consumption demo ready. |
| 112 | + Switch the board's power off and back on now to get correct power consumption readings. |
| 113 | +
|
| 114 | + Woken up 1 time(s) |
| 115 | + Woken up 2 time(s) |
| 116 | + Woken up 3 time(s) |
| 117 | +
|
| 118 | +Dependencies |
| 119 | +************ |
| 120 | + |
| 121 | +This sample uses the following |NCS| library: |
| 122 | + |
| 123 | +* :ref:`lib_ram_pwrdn` |
| 124 | + |
| 125 | +It uses the following Zephyr library: |
| 126 | + |
| 127 | +* :ref:`zephyr:kernel_api` |
| 128 | + |
| 129 | +In addition, the non-secure build uses the following secure firmware component: |
| 130 | + |
| 131 | +* :ref:`Trusted Firmware-M <ug_tfm>` |
0 commit comments