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

NRF 51822, RTC 0 or RTC 1 together with BLE.

Good afternoon. I use NRF 51822, and I want to use RTC 0 or RTC 1. But there are problems, if I do not initialize BLE then the compiler does not execute LFCLK_config because of #ifndef SOFTDEVICE_PRESENT. If I get around this, interruptions cease to occur. Tell me how you can switch the use of the RTC between tasks in one project. I sometimes need to transfer data to the phone, at this time I not use the RTC.

  • I solved the problem.

    static void lfclk_config(void)
    {
    nrf_clock_xtalfreq_set(CLOCK_CONFIG_XTAL_FREQ);
    nrf_clock_lf_src_set((nrf_clock_lf_src_t)CLOCK_CONFIG_LF_SRC);
    nrf_drv_common_irq_enable(POWER_CLOCK_IRQn, 3);
    __disable_irq();
    *((volatile uint32_t *)((uint8_t *)NRF_CLOCK + NRF_CLOCK_TASK_LFCLKSTART)) = NRF_CLOCK_TASK_TRIGGER;
    nrf_task_triger((uint32_t*)NRF_CLOCK,NRF_CLOCK_TASK_LFCLKSTART);
    __enable_irq();
    }

  • Good to hear that you found a solution. Thanks for updating the case. Another alternative that you may consider as well is to keep the Softdevice enabled even if you don't need it, but just stop any ongoing  BLE advertising to prevent connections. The Softdevice will leave the LF clock running. Though you will need to disable the Softdevice to access RTC0.  

Related