nrf5340 Low Frequency Timer (RTC)

Hi,

Is there a known issue with the startup of the LF clock on the nrf5340 app core? I have scanned the nrf5340 errata but do not see anything of note.

I have this code snippet in the Bluetooth stack from our stack vendor:

  /* FIXME workaround for LF OSC startup. */
  nrf_clock_lf_src_set(NRF_CLOCK, NRF_CLOCK_LFCLK_Synth);
  nrfx_clock_lfclk_start();
  while (!nrfx_clock_lfclk_is_running());

With the above code, I was still getting occasional LF clock start up problems so I changed it to:

  /* LFCLKSRC external crystal pin configuration. */
  NRF_P0->PIN_CNF[0] = GPIO_PIN_CNF_MCUSEL_Peripheral << GPIO_PIN_CNF_MCUSEL_Pos;
  NRF_P0->PIN_CNF[1] = GPIO_PIN_CNF_MCUSEL_Peripheral << GPIO_PIN_CNF_MCUSEL_Pos;

  ...
  
  nrf_clock_lf_src_set(NRF_CLOCK, NRF_CLOCK_LFCLK_Xtal);
  nrfx_clock_lfclk_start();
  while (!nrfx_clock_lfclk_is_running());

Unfortunately, this still has problems with the clock startup.

Do you have any insights in how to start the LF clock cleanly?

Regards,

AC

Parents Reply
  • Hi Sigurd,

    Here is my code:

      NRF_P0->PIN_CNF[0] = GPIO_PIN_CNF_MCUSEL_Peripheral << GPIO_PIN_CNF_MCUSEL_Pos;
      NRF_P0->PIN_CNF[1] = GPIO_PIN_CNF_MCUSEL_Peripheral << GPIO_PIN_CNF_MCUSEL_Pos;
    
      err = nrfx_clock_init(palSysWakeupClockEvent);
      PAL_SYS_ASSERT(err == NRFX_SUCCESS);
      nrfx_clock_enable();
    
      /* Use 128 MHz clock. */
      //err = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);
      //PAL_SYS_ASSERT(err == NRFX_SUCCESS);
      // FIXME: Replace following with nrfx_clock_divider_set()
      NRF_CLOCK->HFCLKCTRL = CLOCK_HFCLKCTRL_HCLK_Div1;
      nrfx_clock_hfclk_start();
      while (!nrfx_clock_hfclk_is_running());
    
      /* FIXME workaround for LF OSC startup. */
      // Amp modified (AC) - set source to external crystal
    //  nrf_clock_lf_src_set(NRF_CLOCK, NRF_CLOCK_LFCLK_Synth);
      nrf_clock_lf_src_set(NRF_CLOCK, NRF_CLOCK_LFCLK_Xtal);
      nrfx_clock_lfclk_start();
      while (!nrfx_clock_lfclk_is_running());
    

    This is a custom board but take note that the vendor uses the PCA10095 as their hardware platform so the notation about the workaround is relating to the PCA10095 board.

    As mentioned previously, the code blocks on 

    while (!nrfx_clock_lfclk_is_running());

    when using either the synth or external source for the LF oscillator.

    When using the external crystal as the clock source, it is using external capacitors:

    Regards,

    AC

Children
Related