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

lfclk initialization trouble when switching between ble and esb

Hello,

In my application I want to switch between using bluetooth low energy and enhanced shockburst (esb). I have tried using the timeslot api to run both of them together, but although it works very well, waiting for available timeslots severely limits the speed at which I can send data to my esb receiver.

To get around this problem I would like to switch between protocols - that is, I want to disable the BLE protocol before enabling the ESB protocol. The problem that I am running into is that I cannot initialize the low frequency clock. Because I have the SOFTDEVICE_PRESENT flag defined but the softdevice disabled, the nrf_drv_clock_init() function throws an error.

I know that the low frequency clock is not needed to use the ESB protocol, but I need my application timers to continue to run.

I have already seen this post, but I cannot remove the SOFTDEVICE_PRESENT flag because I need to use the softdevice when I am in bluetooth mode.

I have also seen this post. This does not fix my problem either. I am already handeling the HFCLK manually. My problem is with the LFCLK.

Is it not possible to switch between BLE and ESB while still using the application timers? Is the timeslot api my only option?

I am using SDK version 11.0.0.

thanks in advance for your thoughts!

Parents
  • FormerMember
    0 FormerMember

    If the softdevice is disabled when you use ESB (you have called sd_ble_disable(..) ), it will, for the application, be the same as if the softdevice wasn't present. The tag SOFTDEVICE_PRESENT means if the softdevice is present and enabled. In your case, since the softdevice is disabled, "SOFTDEVICE_PRESENT" should be false. You should then be able to initialize the LFCLK when using ESB.

  • here is th logic in the nrf_drv_clock_init() function for reference

    #ifndef SOFTDEVICE_PRESENT
        m_clock_cb.p_lf_head      = NULL;
        m_clock_cb.lfclk_requests = 0;
        nrf_clock_xtalfreq_set(CLOCK_CONFIG_XTAL_FREQ);
        nrf_clock_lf_src_set((nrf_clock_lfclk_t)CLOCK_CONFIG_LF_SRC);
        nrf_drv_common_irq_enable(POWER_CLOCK_IRQn, CLOCK_CONFIG_IRQ_PRIORITY);
    #if CALIBRATION_SUPPORT
        m_clock_cb.cal_state = CAL_STATE_IDLE;
    #endif // CALIBRATION_SUPPORT
    #else // SOFTDEVICE_PRESENT
        uint8_t is_enabled;
        result = sd_softdevice_is_enabled(&is_enabled);
        if((result == NRF_SUCCESS) && !is_enabled)
        {
            result = NRF_ERROR_SOFTDEVICE_NOT_ENABLED;
        }
    #endif // SOFTDEVICE_PRESENT
        m_clock_cb.module_initialized = true;
        return result;
    
Reply
  • here is th logic in the nrf_drv_clock_init() function for reference

    #ifndef SOFTDEVICE_PRESENT
        m_clock_cb.p_lf_head      = NULL;
        m_clock_cb.lfclk_requests = 0;
        nrf_clock_xtalfreq_set(CLOCK_CONFIG_XTAL_FREQ);
        nrf_clock_lf_src_set((nrf_clock_lfclk_t)CLOCK_CONFIG_LF_SRC);
        nrf_drv_common_irq_enable(POWER_CLOCK_IRQn, CLOCK_CONFIG_IRQ_PRIORITY);
    #if CALIBRATION_SUPPORT
        m_clock_cb.cal_state = CAL_STATE_IDLE;
    #endif // CALIBRATION_SUPPORT
    #else // SOFTDEVICE_PRESENT
        uint8_t is_enabled;
        result = sd_softdevice_is_enabled(&is_enabled);
        if((result == NRF_SUCCESS) && !is_enabled)
        {
            result = NRF_ERROR_SOFTDEVICE_NOT_ENABLED;
        }
    #endif // SOFTDEVICE_PRESENT
        m_clock_cb.module_initialized = true;
        return result;
    
Children
No Data
Related