Power management with nRF Connect SDK v2.6.1

Hello,

I want to make periodically wake up nRF52840, performing some work (connecting to MQTT broker, sending some data) and after that going to low power mode. Then the nRF52840 have to be waken up after some time expires [1 - 300] seconds or by an interrupt from an accelerometer.
I have read this can be achieved using `pm_state_force` function. However it seems that this is not the way since nRF Connect SDK v2.5.0. I also read this thread, where is said that pm_suspend_devices function shall be used.

Which is the header for that function, may it is zephyr/kernel/include/kernel_internal.h ?
Can you provide here some guidelines and/or examples of how to deal with such task in nRF Connect v2.6.1.

Regards,
Ivan

Parents
  • Hi,

    Generally, you do not need to use power management directly to achieve low power. (with some exceptions)

    Just do k_sleep() and the device should consume low power already.

    Is there any specific reason to why you try to use the power management API?

    Regards,
    Sigurd Hellesvik

  • Thank you for your answer.

    There is no specific reason to use the power management API. I just want to be sure that the device will consume less current when in idle state. If k_sleep does the work it is fine. From other hand, there is k_cpu_idle() function (I saw an example from chatGPT). Taking in regards your answer, it seems k_sleep is natural way. However, how these functions are related - k_sleep() and k_cpu_idle() ?

  • See https://docs.zephyrproject.org/latest/kernel/services/scheduling/index.html#scheduling

    "Calling k_sleep() makes the thread unready for a specified time period. Ready threads of all priorities are then allowed to execute; however, there is no guarantee that threads whose priority is lower than that of the sleeping thread will actually be scheduled before the sleeping thread becomes ready once again."

    and

    "Although normally reserved for the idle thread, in certain special applications, a thread might want to make the CPU idle."

    So k_sleep() is for your app.

    JWalker said:
    There is no specific reason to use the power management API. I just want to be sure that the device will consume less current when in idle state. If

    The main exception is always-on peripherals with RX modes, such as UART. These will have to be disabled manually to save power, and the power management APIs suspend functionality is used for that.

Reply
  • See https://docs.zephyrproject.org/latest/kernel/services/scheduling/index.html#scheduling

    "Calling k_sleep() makes the thread unready for a specified time period. Ready threads of all priorities are then allowed to execute; however, there is no guarantee that threads whose priority is lower than that of the sleeping thread will actually be scheduled before the sleeping thread becomes ready once again."

    and

    "Although normally reserved for the idle thread, in certain special applications, a thread might want to make the CPU idle."

    So k_sleep() is for your app.

    JWalker said:
    There is no specific reason to use the power management API. I just want to be sure that the device will consume less current when in idle state. If

    The main exception is always-on peripherals with RX modes, such as UART. These will have to be disabled manually to save power, and the power management APIs suspend functionality is used for that.

Children
Related