Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Detect whether HFXO or HFINT is clocking the HFCLK Controller?

nRF52840, SDK 16.0.0, SD132v7.0.1

What's the correct way to tell whether HFXO or HFINT is clocking the HFCLK controller? I'm able to start and stop the HFCLK controller, but how do I find out whether the crystal or internal oscillator is clocking it?

Thanks,

Charles

Parents Reply Children
  • Thanks for the quick response. Just to be very explicit here, so I understand, it looks like there's a discrepancy between the data sheet and the function name there, right?

    HFCLK is described in the nRF52840 datasheet as a controller that can be clocked either by HFXO or HFINT. I see in https://devzone.nordicsemi.com/f/nordic-q-a/55424/hfclk-hfxo-failure-detection that it's not possible to query the case where HFXO has failed (detached during a drop event or something).

    We're performing reliability and system tests and I have a request from that team to detect whether the HFXO is still physically attached and operating.

    sd_clock_hfclk_is_running() claims to tell me if the HFXO is running, despite the name describing HFCLK. SoftDevice appears to only function against HFXO, so the system seems to assume that if SoftDevice is running, HFCLK must be powered by HFXO. The link I posted above indicates that this isn't a correct assumption; SoftDevice does not appear to be capable of understanding that HFXO has failed and that HFINT has taken over as the oscillator source.

    Is there a way to detect whether HFCLK is being clocked by the HFXO or HFINT?

  • it looks like there's a discrepancy between the data sheet and the function name there, right?

    Yes, a more accurate name would be sd_clock_hfxo_is_running.

    so the system seems to assume that if SoftDevice is running, HFCLK must be powered by HFXO

    The SoftDevice will by default only turn the HFXO on when it needs to use the RADIO. But the application can request the SoftDevice to keep the HFXO running, by calling sd_clock_hfclk_request().

    Is there a way to detect whether HFCLK is being clocked by the HFXO or HFINT?

    You can read the HFCLKSTAT register. If the SRC is Xtal, and running is 1, then it's clocked by HFXO.

     

Related