nRF52832 System ON Run modes of consumption

Hello,

I am working in a project using the nRF52832 SoC, on the nRF5_SDK_17.1.0, using the Softdevice S132 and working over the SES IDE. For managing the consumption I have seen some cases related tonthe System On and System Off options using Softdevice. However, what I have found is more concerned to put the device in sleep mode by different systems and waking the device using events. In my case, I should consider the nRF52832 always in Run mode using the external 32MHz crystal (I have no one external 32KHz crystal).

Is there a way to modifiy and reduce the consumption in some moments keeping the device running? For example:

- Modifying the HFCLK clock frequency dinamically while the BLE module would not be needed.

- Deactivating and reenabling dinamically internal peripherals.

Thank you very much in advance.

Regards,

Joel

Parents
  • Hi Einar,

    Thank you for your answer.

    I'm using the nRF52832 SoC over nRF5_SDK_17.1.0 and the SES IDE.

    Einar Thorsrud said:
    No, that is not possible. However, the nRF will normally use the HFINT which is an high frequency RC oscillator when there is no need for a highly accurate clock.

    - Usually in other microcontrollers the total consumption may be reduced by dividing the clock that use the CPU and the peripherals, although the main crystal oscillator could be running. Are there no instructions for this, then?

    - What are the function calls or instructions to switch between the internal 32.768KHz LFRC oscillator and the HFCLK?

    -

    Einar Thorsrud said:
    If using the nRF5 SDK, the main thread of the examples will typicall enter system ON low power mode in the main loop by calling sd_app_evt_wait(), via the power management library

    I have seen this functions in other cases and I will be able to use it probably in a part of the code. But there will be other cases in the machine state of the application wher I cannot enter into a wait state. In these last cases (in fact, the more usual) where I would try to reduce the consumption by reducing the oscillator frequency or switching to tha LFRC oscillator.

    Regards,

    Joel

Reply
  • Hi Einar,

    Thank you for your answer.

    I'm using the nRF52832 SoC over nRF5_SDK_17.1.0 and the SES IDE.

    Einar Thorsrud said:
    No, that is not possible. However, the nRF will normally use the HFINT which is an high frequency RC oscillator when there is no need for a highly accurate clock.

    - Usually in other microcontrollers the total consumption may be reduced by dividing the clock that use the CPU and the peripherals, although the main crystal oscillator could be running. Are there no instructions for this, then?

    - What are the function calls or instructions to switch between the internal 32.768KHz LFRC oscillator and the HFCLK?

    -

    Einar Thorsrud said:
    If using the nRF5 SDK, the main thread of the examples will typicall enter system ON low power mode in the main loop by calling sd_app_evt_wait(), via the power management library

    I have seen this functions in other cases and I will be able to use it probably in a part of the code. But there will be other cases in the machine state of the application wher I cannot enter into a wait state. In these last cases (in fact, the more usual) where I would try to reduce the consumption by reducing the oscillator frequency or switching to tha LFRC oscillator.

    Regards,

    Joel

Children
  • jinvers said:
    - Usually in other microcontrollers the total consumption may be reduced by dividing the clock that use the CPU and the peripherals, although the main crystal oscillator could be running. Are there no instructions for this, then?

    That is not supported on the nRF5 devices. On the nRF52 series the high frequency clock is always 64 MHz. However, this clock only runs when needed. The only clock that always runs is the 32.768 kHz clock. The paradigm used for power optimization in the nRF devices is "race to idle".

    jinvers said:
    - What are the function calls or instructions to switch between the internal 32.768KHz LFRC oscillator and the HFCLK?

    You don't normally switch. If you have a 32.768 kHz crystal you always use that. If not, you use the RC. As you use the SoftDevice this is part of the SoftDevice configuration, and you adjust sdk_config.h as explained in this post.

    jinvers said:
    I have seen this functions in other cases and I will be able to use it probably in a part of the code. But there will be other cases in the machine state of the application wher I cannot enter into a wait state. In these last cases (in fact, the more usual) where I would try to reduce the consumption by reducing the oscillator frequency or switching to tha LFRC oscillator.

    I think you misunderstood how this works. sd_app_evt_wait waits indefinitely, and most applications only include this in a single place, which is in your application main loop. The way this then works is that whenever the device wakes up on an interrupt, the main loop runs after the interrupts are processed, and then all other calls in the main loop is run once until calling sd_app_evt_wait(). This way the CPU sleeps when not in use instead of spending CPU cycles doing nothing. You can see this being used in virtually all SDK examples.

    Also, the CPU can never run of the LFRC. Only a few selected low power peripherals use the LFRC, most notably the RTC, which is used to keep basic track of time for when to wake up. For instance, when in a BLE connection, the RTC is used to wake up the device before every advertising event, connection event, and so on.

  • Hi Einar,

    That is not supported on the nRF5 devices. On the nRF52 series the high frequency clock is always 64 MHz. However, this clock only runs when needed. The only clock that always runs is the 32.768 kHz clock. The paradigm used for power optimization in the nRF devices is "race to idle".

    So definitely I cannot stop the main HFCLK using external 32MHz crystal. Is this correct?

    You don't normally switch. If you have a 32.768 kHz crystal you always use that. If not, you use the RC. As you use the SoftDevice this is part of the SoftDevice configuration, and you adjust sdk_config.h as explained in this post.

    Using the sdk_config.h implies make the selection in the design phase and not in the execution phase.

    I think you misunderstood how this works. sd_app_evt_wait waits indefinitel

    I have understood it well. Considering your other answers, I see that the options are very limited.

    Regards,

    Joel

  • jinvers said:
    So definitely I cannot stop the main HFCLK using external 32MHz crystal. Is this correct?

    No. The CPU will always need a 64 kHz clock while running (meaning when not in sleep), but that can be generated from either HFINT (RC) or HFXO (the latter is needed when an accurate clock is needed, like when using the radio). Switching between the two oscillators is seemless. And when the clock is not needed (like when the CPU and other peripherals that runs of the HF clock is sleeping or disabled), the HFCLK (regardless of source) can be disabled.

    jinvers said:
    Using the sdk_config.h implies make the selection in the design phase and not in the execution phase.

    Yes. I cannot think of any real world use cases where you would want to ever use LFRC if your board has an onboard 32.768 kHz crystal.

  • Hi Einar,

    Excuse me if I have not explained well. The board has not an onboard 32.768KHz crystal. The question, then, is how (in execution time) is it possible to disable the HFCLK to use the LFRC and just th other way round.

    Regards,

    Joel

  • jinvers said:
    Excuse me if I have not explained well. The board has not an onboard 32.768KHz crystal.

    I understand, that is why I explained how to configure an LFRC. And the mentionning of no need to dynamically switch was as a comment to why this is done build time as you did not like that (I don't see any reason this should be runtime).

    jinvers said:
    The question, then, is how (in execution time) is it possible to disable the HFCLK to use the LFRC and just th other way round.

    As mentioned, the CPU always needs the HFCLK while running. When the CPU is sleeping (which is after a __WFE() or __WFI() instruction, typically after calling sd_app_evt_wait() when using a SoftDevice), and no other peripherals are requesting the HFCLK, this is disabled. The SoftDevice always keeps the LFCLK and RTC0 running for time keeping. RTC1 is also typically used by the app_timer library. You can see how this is done in any Bluetooth example in the SDK.

Related