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

hang in sd_softdevice_enable() when use nRF52840 Internal oscillator

Hi,

I am try to configure internal RC (LFCLK) but device hang in "sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler);" API.

Changed in  "sdk_config.h" to enable internal RC.

Used "...\...\nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_hrs\pca10056\s140\arm5_no_packs" HRS sample code.

// </h> 
//==========================================================

// <h> Clock - SoftDevice clock configuration

//==========================================================
// <o> NRF_SDH_CLOCK_LF_SRC  - SoftDevice clock source.
 
// <0=> NRF_CLOCK_LF_SRC_RC 
// <1=> NRF_CLOCK_LF_SRC_XTAL 
// <2=> NRF_CLOCK_LF_SRC_SYNTH 

#ifndef NRF_SDH_CLOCK_LF_SRC
#define NRF_SDH_CLOCK_LF_SRC 0
#endif

// <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. 
#ifndef NRF_SDH_CLOCK_LF_RC_CTIV
#define NRF_SDH_CLOCK_LF_RC_CTIV 16
#endif

// <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. 
// <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
// <i>  if the temperature has not changed.

#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
#endif

// <o> NRF_SDH_CLOCK_LF_ACCURACY  - External clock accuracy used in the LL to compute timing.
 
// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM 
// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM 
// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM 
// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM 
// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM 
// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM 
// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM 
// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM 
// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM 
// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM 
// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM 
// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM 

#ifndef NRF_SDH_CLOCK_LF_ACCURACY
#define NRF_SDH_CLOCK_LF_ACCURACY 1
#endif

Ref link: https://devzone.nordicsemi.com/f/nordic-q-a/50338/nrf52840-internal-oscillator-soft-device-enable-hanging?ReplySortBy=CreatedDate&ReplySortOrder=Descending

Thanks,

Nirav Patel

Parents
  • Hi,

    How have you verified that it hangs in sd_softdevice_enable()? That will happen if you configure the SoftDevice to start the xtal oscillator and the xtal is not in the HW. Your sdk_config.h configuration seems sensible, but it is the configuration for the SoftDevice handler library and it seems you are calling sd_softdevice_enable() directly. I cannot tell from your question how you have populated clock_lf_cfg. Can you share that? I suspect that it is not using the SDH configuration you from your sdk_config.h.

  • Thanks, Einar Thorsrud,

    How have you verified that it hangs in sd_softdevice_enable()?

    ==> In debug mode

    That will happen if you configure the SoftDevice to start the xtal oscillator and the xtal is not in the HW.

    ==>Used nRF52840 DK (PCA10056) for testing.

    Your sdk_config.h configuration seems sensible, but it is the configuration for the SoftDevice handler library and it seems you are calling sd_softdevice_enable() directly.

    I cannot tell from your question how you have populated clock_lf_cfg. Can you share that?

    ==> I made only below changes in HRS example:

    "...\...\nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_hrs\pca10056\s140\arm5_no_packs"

    // </h> 
    //==========================================================
    
    // <h> Clock - SoftDevice clock configuration
    
    //==========================================================
    // <o> NRF_SDH_CLOCK_LF_SRC  - SoftDevice clock source.
     
    // <0=> NRF_CLOCK_LF_SRC_RC 
    // <1=> NRF_CLOCK_LF_SRC_XTAL 
    // <2=> NRF_CLOCK_LF_SRC_SYNTH 
    
    #ifndef NRF_SDH_CLOCK_LF_SRC
    #define NRF_SDH_CLOCK_LF_SRC 0
    #endif
    
    // <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. 
    #ifndef NRF_SDH_CLOCK_LF_RC_CTIV
    #define NRF_SDH_CLOCK_LF_RC_CTIV 16
    #endif
    
    // <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. 
    // <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
    // <i>  if the temperature has not changed.
    
    #ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
    #define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
    #endif
    
    // <o> NRF_SDH_CLOCK_LF_ACCURACY  - External clock accuracy used in the LL to compute timing.
     
    // <0=> NRF_CLOCK_LF_ACCURACY_250_PPM 
    // <1=> NRF_CLOCK_LF_ACCURACY_500_PPM 
    // <2=> NRF_CLOCK_LF_ACCURACY_150_PPM 
    // <3=> NRF_CLOCK_LF_ACCURACY_100_PPM 
    // <4=> NRF_CLOCK_LF_ACCURACY_75_PPM 
    // <5=> NRF_CLOCK_LF_ACCURACY_50_PPM 
    // <6=> NRF_CLOCK_LF_ACCURACY_30_PPM 
    // <7=> NRF_CLOCK_LF_ACCURACY_20_PPM 
    // <8=> NRF_CLOCK_LF_ACCURACY_10_PPM 
    // <9=> NRF_CLOCK_LF_ACCURACY_5_PPM 
    // <10=> NRF_CLOCK_LF_ACCURACY_2_PPM 
    // <11=> NRF_CLOCK_LF_ACCURACY_1_PPM 
    
    #ifndef NRF_SDH_CLOCK_LF_ACCURACY
    #define NRF_SDH_CLOCK_LF_ACCURACY 1
    #endif

    ==> I am not sure but are you want to know about below configuration: (clock_lf_cfg)

    ret_code_t nrf_sdh_enable_request(void)
    {
        ret_code_t ret_code;
    
        if (m_nrf_sdh_enabled)
        {
            return NRF_ERROR_INVALID_STATE;
        }
    
        m_nrf_sdh_continue = true;
    
        // Notify observers about SoftDevice enable request.
        if (sdh_request_observer_notify(NRF_SDH_EVT_ENABLE_REQUEST) == NRF_ERROR_BUSY)
        {
            // Enable process was stopped.
            return NRF_SUCCESS;
        }
    
        // Notify observers about starting SoftDevice enable process.
        sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLE_PREPARE);
    
        nrf_clock_lf_cfg_t const clock_lf_cfg =
        {
            .source       = NRF_SDH_CLOCK_LF_SRC,
            .rc_ctiv      = NRF_SDH_CLOCK_LF_RC_CTIV,
            .rc_temp_ctiv = NRF_SDH_CLOCK_LF_RC_TEMP_CTIV,
            .accuracy     = NRF_SDH_CLOCK_LF_ACCURACY
        };
    
        CRITICAL_REGION_ENTER();
    #ifdef ANT_LICENSE_KEY
        ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler, ANT_LICENSE_KEY);
    #else
        ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler);
    #endif
        m_nrf_sdh_enabled = (ret_code == NRF_SUCCESS);
        CRITICAL_REGION_EXIT();
    
        if (ret_code != NRF_SUCCESS)
        {
            return ret_code;
        }
    
        m_nrf_sdh_continue  = false;
        m_nrf_sdh_suspended = false;
    
        // Enable event interrupt.
        // Interrupt priority has already been set by the stack.
        softdevices_evt_irq_enable();
    
        // Notify observers about a finished SoftDevice enable process.
        sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLED);
    
        return NRF_SUCCESS;
    }

     

    I suspect that it is not using the SDH configuration you from your sdk_config.h.

    ==> How can I check that?

    --

    Nirav Patel

  • Hi,

    Let me just recap the previous post:

    • You are testing on the nRF52840 DK.
    • You are testing the \examples\ble_peripheral\ble_app_hrs\pca10056\s140\arm5_no_packs example project in SDK 15.2
    • Your only modification is what you have listed for the projects sdk_config.h (which is the correct settings for using the internal 32.768 kHz RC oscillator).

    Is this correct? Or have you made other modifications as well? I ask because there is nothing wrong with what you described, and I just tested the example with the modifications you have described, and it works as expected. Please explain any other modifications you have made, and please upload your complete zipped example project so that I can see if there are any other changes.

  • Hi Einar,

    PCA10056 (V0.9.0) DK used for test

    Nirav Patel

  • Hi,

    I see. I am not able to reproduce this issue with the production chip, but I can reproduce it with 0.9.0, which has an old engineering sample IC. You should not use that for development, as the chip has a number of issues that were fixed in the production version. The release SoftDevice and SDK's no longer include workarounds for issues that were fixed in the production version (revision 1). So the recommendation here is to test with a newer version of the nRF52840 DK (PCA10056) - at least one which has the production IC.

Reply
  • Hi,

    I see. I am not able to reproduce this issue with the production chip, but I can reproduce it with 0.9.0, which has an old engineering sample IC. You should not use that for development, as the chip has a number of issues that were fixed in the production version. The release SoftDevice and SDK's no longer include workarounds for issues that were fixed in the production version (revision 1). So the recommendation here is to test with a newer version of the nRF52840 DK (PCA10056) - at least one which has the production IC.

Children
Related