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

How to detect the external low-frequency vibration crystal work?When it doesn't work how to switch frequency crystals?

52832,SDK12.0.0

I met such a situation: In the use of JLink burning program or air upgrade, after the completion of the program card died in initialization low-frequency crystals.

"sd_softdevice_enable(p_clock_lf_cfg, softdevice_fault_handler);"

  • Before 52832 program into the main function, initialize the clock: Under normal circumstances: NRF_CLOCK - > LFCLKSTAT = 0; After the abnormal: NRF_CLOCK - > LFCLKSTAT = 0 x00010000, (1 low frequency clock is still running, 00 said RC internal clock)

    Now, initialize the clock before I join lfclk_stop (), the program will stuck waiting for the clock stopped while (nrf_clock_lf_is_running ())

        // Low frequency clock source to be used by the SoftDevice
    #define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_XTAL,            \
                                     .rc_ctiv       = 0,                                \
                                     .rc_temp_ctiv  = 0,                                \
                                     .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
    
  • After initialization, you mean that after you've called sd_softdevice_enable with the following clock config

        // Low frequency clock source to be used by the SoftDevice
    #define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_XTAL,            \
                                     .rc_ctiv       = 0,                                \
                                     .rc_temp_ctiv  = 0,                                \
                                     .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
    

    then you read 0x00010000 from the LFCLKSTAT register?

  • yes.I read 0x00010000 from the LFCLKSTAT register. I use projects: SDK12.0.0 ; examples\ble_peripheral\ble_app_hrs_freertos The following code:

    int main(void)
    {
        ret_code_t err_code;
        uint32_t lfclk_state = 1;
        
        while(lfclk_state)
        {
            lfclk_state = NRF_CLOCK->LFCLKSTAT; //lfclk_state =0x00010000
        }
        
        err_code = nrf_drv_clock_init();
        APP_ERROR_CHECK(err_code);
    ....
    }
    

    After the exception occurs, I put the low-frequency clock configuration set to use internal frequency clock, the program can run, but related to low frequency clock driver is invalid, such as app_timer, WDT, etc

    After this exception occurs,Cut off the chip power supply, and then to electricity to make the program run normally

  • I apologize, I referred to an incorrect register value( 0x8001) and corrected my comment. The default value of the LFCLKSRC is 0x00000000 so if you start the LFCLK using the TASKS_LFCLKSTART task then you will read 0x00010000. I still do not understand why you need to check this.

  • When using external low-frequency crystals, if NRF_CLOCK - > LFCLKSTAT = = 0 x00010000, the program will stuck in sd_softdevice_enable (p_clock_lf_cfg softdevice_fault_handler); In the use of JLink burning program, I met many times this exception, air upgrade also appeared in the process.

Related