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

Zigbee Light Switch Example running with internal RC

Is it possible to run the Zigbee Light Switch example with the internal RC.?

On the sdk_config.h I have changed the following:

#define NRFX_CLOCK_CONFIG_LF_SRC 0

But the device will get stuck at ZB_INIT() call, specifically on this function:

Any help is most welcome!

Thanks

  • Hi

    It should not be an issue using the internal RC oscillator in Zigbee projects. However, you have to do a few more changes in your sdk_config.h file in order to enable the RC oscillator. Please make sure that the following defines are changed to the values below:

    // <o> CLOCK_CONFIG_LF_SRC  - LF Clock Source
     
    // <0=> RC 
    // <1=> XTAL 
    // <2=> Synth 
    // <131073=> External Low Swing 
    // <196609=> External Full Swing 
    
    #ifndef CLOCK_CONFIG_LF_SRC
    #define CLOCK_CONFIG_LF_SRC 0
    #endif
    
    // <q> CLOCK_CONFIG_LF_CAL_ENABLED  - Calibration enable for LF Clock Source
     
    
    #ifndef CLOCK_CONFIG_LF_CAL_ENABLED
    #define CLOCK_CONFIG_LF_CAL_ENABLED 1
    #endif
    
    // <o> CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    
    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    // <o> NRFX_CLOCK_CONFIG_LF_SRC  - LF Clock Source
     
    // <0=> RC 
    // <1=> XTAL 
    // <2=> Synth 
    // <131073=> External Low Swing 
    // <196609=> External Full Swing 
    
    #ifndef NRFX_CLOCK_CONFIG_LF_SRC
    #define NRFX_CLOCK_CONFIG_LF_SRC 1
    #endif

    Best regards,

    Simon

  • Hi Simonr,

    Thanks for your reply. I believe the suggested changes are suitable for a project that uses a softdevice implementation. The Zigbee Light Switch example uses the ZBOSS library. The options mentioned are not listed on the sdk_config.h file of the Zigbee Light Switch example. Could you try to modify the code as I suggested and run the project on debug mode? Can you see if the micro executes any further than the ZB_INIT() function or it gets stuck there?

    Many thanks 

  • Hi Ignacio

    You're absolutely right. Sorry, been a while since I looked into Zigbee and forgot it doesn't use the SoftDevice. I have edited my previous reply to avoid confusion for people with the same problem in the future, it should not reflect what defines you need to change in order to enable the RC clock.

    It seems like you have to do the calibration process of the RC clock manually when the SoftDevice isn't enabled, so you will have to use a timer (app_timer or a TIMER) and call the nrf_drv_clock_calibration_start (check out nrf_drv_clock.h for more info on the calibration functions) every 4-8 seconds in order to ensure that the RC clock stays calibrated.

    Best regards,

    Simon

  • Hi Simonr,

    Thanks for the update. That was really helpful.

    I have set the below flag as indicated:

    #define CLOCK_CONFIG_LF_CAL_ENABLED 1

    That seems to be the main issue. I have flashed the device with the updated code and it has been working fine for good while.  Is it strictly required to manually calibrate the RC clock? Would it be a connection issue if RC clock is not manually calibrated?

    Thanks

  • Hi

    We strongly recommend that the LFRC oscillator is calibrated in order to improve accuracy, as not doing so may result in drift and inaccuracy of the clock. The frequency tolerance with calibration is +-500ppm, while the frequency tolerance without calibration is +2%. It is recommended that the calibration is performed at least every 8 seconds with a constant temperature within +-0.5 °C. 

    Not calibrating the RC clock shouldn't cause connection issues, as radio communication uses the HFCLK, but timers in low power mode, etc. may get inaccurate by not calibrating the LFRC clock.

    Best regards,

    Simon

Related