A sample for CAF power manager module

Hi Support team,

Is there a sample for how to use the CAF power manager module?

there are several components of power management(PM) in NCS and Zephyr:
    (1) 'NCS CAF power manager module',
    (2) system power management in Zephyr PM subsystem,
    (3) device power management in Zephyr PM subsystem,
    (4) device runtime power management in Zephyr PM subsystem

To construct a complete power management on the application core of nRF5340, for example, can set the application core to low power mode when no task running, and can power off peripherals freely and as much as possible to save power. etc, which components will be used? and what are the steps to do it?

In our application, we only collect sensor data on the application core, and will not use the short-range radio protocols.

Any guidance or hints are appreciated, thank you very much.

Parents
  • Hi,

    The power management is mostly automated when you use Zephyr with the nRF53 series. The program will automatically enter the idle thread where the chip will enter  System ON mode when there is no work to do. The exception is when you use QSPI NOR flash, UART, or similar that must be actively suspended by the application when not needed. This can be done with the device power management API. 

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/test_and_optimize/optimizing/power_general.html 

    Best regards,

    Vidar

  • Hi Vidar,

    Thanks for your reply and the valuable information. Could I confirm several points of my understanding?

    1 For system power management, I don't need to do anything, the APIs pm_system_suspend() and pm_system_resume() in /zephyr/subsys/pm/pm.c are kernel callback and will be called by OS automatically to follow the idle thread, and can be in the state of OS-IDLE and OS-SUSPENDED at the right time?
    2 What need I to do is the devices power management, I can manage power consumption of UART/SPI/I2C and QSPI Nor flash with the API pm_device_action_run()?

    If it is in this way, the power management on our application are much clear.
    Thank you very much.

  • Hi ,

    1 For system power management, I don't need to do anything, the APIs pm_system_suspend() and pm_system_resume() in /zephyr/subsys/pm/pm.c are kernel callback and will be called by OS automatically to follow the idle thread, and can be in the state of OS-IDLE and OS-SUSPENDED at the right time?

    The power management subsystem is actually disabled by default starting from SDK 2.5.0: https://github.com/nrfconnect/sdk-zephyr/commit/96b38273138f05dd06cf7a58fa361f401e773e5e.  

    2 What need I to do is the devices power management, I can manage power consumption of UART/SPI/I2C and QSPI Nor flash with the API pm_device_action_run()?

    Correct. Also, SPI, I2C does not need to be suspended as they power down automatically after transactions are completed. The reason UART must be suspended manually is that they system doesn't know when the UART must be ready to receive data. Suspending a QSPI NOR device also involves sending a sleep instruction to the connected flash IC (this happens automatically when you call pm_device_action_run() here: link if the IC supports DPD mode) 

    Best regards,

    Vidar

  • Hi Vidar,

    Thank you so much for these guidance, which are much helpful:).

    Best regards,

    Yanpeng Wu

  • Hi again,

    I want to try the lower power mode of QSPI flash on nRF5340 DK, because there is the same flash device on our custom board.
    I started with the sample 'Multicore Hello World application', and the planned steps are to get the device struct of the external flash device, then use pm_device_action_run() to suspend and resume it.

    I tried two ways as below:
    1   const struct device *const dev_QSPINorFlash = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash));
          if (!device_is_ready(dev_QSPINorFlash)) {
                printk("%s: External Flash not ready.\n", dev_QSPINorFlash->name);
                return 0;
          } else {
                printk("%s: External Flash ready.\n", dev_QSPINorFlash->name);
          }

          Compile error: C:\ncs\v2.5.0\modules\hal\nordic\nrfx\hal\nrf_reset.h:190: undefined reference to `__device_dts_ord_126'

    2 const struct device *const dev_QSPINorFlash = DEVICE_DT_GET(DT_ALIAS(spi_flash0));
          if (!device_is_ready(dev_QSPINorFlash)) {
                printk("%s: External Flash not ready.\n", dev_QSPINorFlash->name);
                return 0;
          } else {
                printk("%s: External Flash ready.\n", dev_QSPINorFlash->name);
          }
          Compile error: C:\ncs\v2.5.0\modules\hal\nordic\nrfx\hal\nrf_reset.h:190: undefined reference to `__device_dts_ord_138'

    But the flash device was defined in the project both with 'aliases' and 'chosen' as below:

    Can I do it this way? Could you help give some guidance? Thank you very much.

Reply
  • Hi again,

    I want to try the lower power mode of QSPI flash on nRF5340 DK, because there is the same flash device on our custom board.
    I started with the sample 'Multicore Hello World application', and the planned steps are to get the device struct of the external flash device, then use pm_device_action_run() to suspend and resume it.

    I tried two ways as below:
    1   const struct device *const dev_QSPINorFlash = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash));
          if (!device_is_ready(dev_QSPINorFlash)) {
                printk("%s: External Flash not ready.\n", dev_QSPINorFlash->name);
                return 0;
          } else {
                printk("%s: External Flash ready.\n", dev_QSPINorFlash->name);
          }

          Compile error: C:\ncs\v2.5.0\modules\hal\nordic\nrfx\hal\nrf_reset.h:190: undefined reference to `__device_dts_ord_126'

    2 const struct device *const dev_QSPINorFlash = DEVICE_DT_GET(DT_ALIAS(spi_flash0));
          if (!device_is_ready(dev_QSPINorFlash)) {
                printk("%s: External Flash not ready.\n", dev_QSPINorFlash->name);
                return 0;
          } else {
                printk("%s: External Flash ready.\n", dev_QSPINorFlash->name);
          }
          Compile error: C:\ncs\v2.5.0\modules\hal\nordic\nrfx\hal\nrf_reset.h:190: undefined reference to `__device_dts_ord_138'

    But the flash device was defined in the project both with 'aliases' and 'chosen' as below:

    Can I do it this way? Could you help give some guidance? Thank you very much.

Children
Related