Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Reduce power consumption through dynamic HFXO request/release operations with softdevice

We have a BLE, battery powered device where we'd like to enter low power modes whenever possible by dynamically switching between HFXO and HFINT such that our application only enables the HFXO when performing a set of actions requiring a more accurate clock source. We recently introduced an application level method to request and release the HFXO clock (via nrfx's nrf_drv_clock_hfclk_request and nrf_drv_clock_hfclk_release) for occasional application behavior not related to BLE that needs HFXO enabled for clock accuracy. The SoftDevice is also present and handling BLE operations with the HFXO as expected.

Despite adding the app level HFXO interaction, the request and release calls (via nrf_drv_clock_hfclk_request  and nrf_drv_clock_hfclk_release ) hard fault when the soft device service call occurs (hard fault traced to sd_clock_hfclk_request/release ).

Device context:

  • nRF5 SDK v15.3.0 (S140 SoftDevice v6.1.1)
  • nrf52840 with external crystal oscillator (64 MHz driven by 32 MHz crystal)

Existing Nordic Q&A posts:

Are there any obvious barriers to dynamically requesting and releasing the HFXO from the app level when the SoftDevice is present?

Does Nordic have any examples or documentation where such an interaction with the HFXO occurs?

  • Hi,

    Are there any obvious barriers to dynamically requesting and releasing the HFXO from the app level when the SoftDevice is present?

    As long as you go through the Softdevice API then it should be fine, 

    We recently introduced an application level method to request and release the HFXO clock (via nrfx's nrf_drv_clock_hfclk_request and nrf_drv_clock_hfclk_release) for occasional application behavior not related to BLE that needs HFXO enabled for clock accuracy. The SoftDevice is also present and handling BLE operations with the HFXO as expected.

    Can share this code?

    regards

    Jared 

  • Thanks for the response, Jared. We've managed to identify the root cause of our issue.

    Root cause:


    Paths forward:

    • Alter the critical section definition to block at lower interrupt priority levels (and therefore allow the SD API at level 4 which may not be feasible or safe)
    • Move away from the critical section and implement thread protection via something like a binary semaphore
Related