This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

what happens if LFCLKSRC that is selected isn't available (for ex:- goes missing)

On nRF52832,

A1> Out of the Softdevice scope: if we are using RTC and have LFCLKSRC configured to XTAL source and if XTAL source gets turned off for some reason what happens. Does the system automatically switch to LFRC source? any NMI or event generated for software to know/handle?

Also when using s132 Softdevice,

B1> what happens if the softdevice is started with LFCLKSRC missing (Configure LFCLKSRC to XTAL and XTAL is not available)?

B2.> what happens if the XTAL goes missing during run time? is there any interrupt generated?

Is there any documentation available that shows the nRF52832 behavior for above scenarios?

Best Regards

Santosh Athuru

Parents
  • Hi,

    Does the system automatically switch to LFRC source?

    No.

    any NMI or event generated for software to know/handle?

    No.

    what happens if the softdevice is started with LFCLKSRC missing (Configure LFCLKSRC to XTAL and XTAL is not available)?

    It will indefinitely wait for the LFCLK XTAL to start. You will be stuck in sd_softdevice_enable().

    what happens if the XTAL goes missing during run time? is there any interrupt generated?

    The code will likely assert and reset.

    Is there any documentation available that shows the nRF52832 behavior for above scenarios?

    Not specifically. If you are worried for the scenario you describe, you could implemented a LFCLK XTAL test function, that you run before you enable the SD. The function could check that you are able to start the LFCLK with XTAL within some time limit. If the test passes, use XTAL, if not use RC.

  • Does the system automatically switch to LFRC source?

    No.

    In the above use case , Softdevice is not enabled yet, so what is CPU doing, I mean which clock source is the CPU running off at this time. If the LFCLKSRC that is chosen is not available, RTC will not run, correct? but will the CPU be running?

    what happens if the softdevice is started with LFCLKSRC missing (Configure LFCLKSRC to XTAL and XTAL is not available)?

    It will indefinitely wait for the LFCLK XTAL to start. You will be stuck in sd_softdevice_enable().

    In the above use case, softdevice is being enabled. Can you clarify 'stuck in sd_softdevice_enable()' ? CPU is running, but the SW is waiting for some event...forever? Again which clock source is CPU running off?

    what happens if the XTAL goes missing during run time? is there any interrupt generated?

    The code will likely assert and reset.

    I don't see a reset happening here, it looks like Nordic pauses and resumes back when the XTAL is available. I need some way to correctly confirm this behavior while using soft device. Please advise.

    One of the problems, I'm looking at is,if Radio is transmitting while the clock goes missing and if the Nordic is stuck in that state then it keeps drawing extra current?

    Best Regards

    Santosh Athuru

  • Softdevice is not enabled yet, so what is CPU doing, I mean which clock source is the CPU running off at this time.

    The CPU is not using the LFCLK, the CPU uses the HFCLK, see the figure at this page.

    If the LFCLKSRC that is chosen is not available, RTC will not run, correct?

    The RTC itself will still work, it can run from internal RC oscillator. But if LFCLK XTAL is chosen, but not available, you will be stuck in sd_softdevice_enable().

    Can you clarify 'stuck in sd_softdevice_enable()' ? CPU is running, but the SW is waiting for some event...forever?

    The CPU will enter WFE(Wait For Event) sleep, while waiting for the LFCLKSTARTED event.

    Again which clock source is CPU running off?

    HFCLK(If HFXO is not explicitly started, it will run from 64 MHz internal oscillator(HFINT)).

    I don't see a reset happening here, it looks like Nordic pauses and resumes back when the XTAL is available. I need some way to correctly confirm this behavior while using soft device.

    I have not tested it, but I find the behavior you describe feasible. How did you test this ?

  • I've a reboot counter that is incremented every time code is run after reboot. So I can tell reboot isn't happening, also there are some IO, I monitor on scope.

    The CPU will enter WFE(Wait For Event) sleep, while waiting for the LFCLKSTARTED event.

    If we start our application with LFCLKSRC = 1, XTAL is missing, so RTC assumes LFRC as source and runs. We don't wait for any Clock started event in our code and start softdevice. Now, softdevice is trying to use XTAL as LFCLKSRC and is stuck doing something. Here we observe about 2mA of current draw, till XTAL is available.

    But, if we start our application with LFCLKSRC = 0, XTAL is missing, RTC uses LFRC as source. We configure softdevice to use XTAL as LFCLKSRC, soft device is stuck waiting for XTAL. Here we don't see the 2mA current draw we saw in above case.

    So we are wondering what inside softdevice is causing this extra 2mA current draw in first case above.

    Best Regards

    Santosh Athuru

  • If the LFCLK is already started or in the process of starting with the correct clock source(XTAL), the SD will just wait for the LFCLKSTAT SRC to change from RC to XTAL. It's the CPU current you are seeing here.

Reply Children
  • Thanks, so there is a WFE based wait (based on your response above) and a CPU loop waiting for LFCLKSTAT SRC.

    The former one comes in based on clock_lf_cfg (nrf_sdh.c) and irrespective of LFCLKSRC it doesn't consume extra current because it is WFE based wait. I didn't see the extra current and I didn't see Softdevice running either here, if XTAL is OFF and clock_lf_cfg.source = 1.

    The latter one, however, puts the CPU in a spin loop which results in extra current draw, if XTAL is not available when LFCLKSRC is set to 1.

    Is my understanding right?

    Best Regards

    Santosh Athuru

  • Is my understanding right?

    Yes. If the SoftDevice is the one starting the LFCLK, it will wait for LFCLKSTARTED with WFE. But if the application itself started the LFCLK with source XTAL, before enabling the SD with source clock_lf_cfg.source=1 (XTAL), the SoftDevice will detect that the application already started the LFCLK, and will then just loop waiting for LFCLKSTAT SRC to change from RC to XTAL.(and this will never happen if XTAL is missing). If you want to avoid this in your application, then you should wait for LFCLKSTARTED(with WFE) in the application before enabling the SoftDevice.

  • Hi Sigrud,

    sounds good. Thanks for the confirmation.

    -Santosh Athuru

Related