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 Reply
  • 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

Children
  • 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.

  • Hi,

    The '__device_dts_ord_126'' error suggests that the QSPI NOR driver is not enabled in your build. I recommend you try the same with the SPI NOR sample in /zephyr/samples/drivers/spi_flash. If you look at the board specific Kconfig fragment in the boards directory, you can see that it sets CONFIG_NORDIC_QSPI_NOR=y.

    Best regards,

    Vidar

  • Hi Vidar,

    Yes, you are right, I need to enable the QSPI NOR driver with CONFIG_NORDIC_QSPI_NOR=y first.
    I can control the power mode of QSPI NOR Flash successfully now.

    Thank you so much.

    Best regards,
    Yanpeng Wu

Related