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

ser_app_hal_hw_init() : using Internal RC instead of External Oscillator (with softdevice on)

I am looking into using Internal RC instead of External Oscillator (with softdevice on).

The function ser_app_hal_hw_init() uses Xtal clock source by default.

  • Why does it not take clock_source as an argument, which is passed to sd_softdevice_enable() function? (see the code snippet below)

  • Can you please indicate all the places where I need to mention Internal RC as the clock source during initialization to be sure that it is indeed used (with softdevice on)?

uint32_t sd_softdevice_enable(nrf_clock_lfclksrc_t clock_source, softdevice_assertion_handler_t assertion_handler) { uint32_t err_code;

err_code = ser_app_hal_hw_init();

: :

  • Partial answer below. This seems odd to me too, looks like the SDK currently only covers the case for external Low Frequency crystal?

    I made a quick addition covering RC and Synth: In ser_softdevice_handler.c / sd_softdevice_enable() I changed the call to ser_app_hal_hw_init() as

    if(clock_source == NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM) {
        err_code = ser_app_hal_hw_init(CLOCK_LFCLKSRC_SRC_Synth);
    } else {
        if(clock_source <= NRF_CLOCK_LFCLKSRC_XTAL_20_PPM) {
            err_code = ser_app_hal_hw_init(CLOCK_LFCLKSRC_SRC_Xtal);
        } else {
            err_code = ser_app_hal_hw_init(CLOCK_LFCLKSRC_SRC_RC);
        }
    }
    

    And then in ser_app_hal_nrf51.c changed the function see_app_hal_hw_init() to start as

    uint32_t ser_app_hal_hw_init(uint32_t lfclksrc) {
        nrf_gpio_cfg_output(CONN_CHIP_RESET_PIN_NO);
    
        NRF_CLOCK->LFCLKSRC            = (lfclksrc << CLOCK_LFCLKSRC_SRC_Pos);
    

    I'm just learning about the SDK myself there may be better ways to do this.

    With this I can get the clock started with both RS and Synth. The SoftDevice seems to initialize. But starting BLE still fails with m_os_rsp_wait_handler() never returning.

    Pertti

Related