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

RC LFCLK and App Timer without SoftDevice SDK13

I am taking the Radio Test example and introducing a button and LED for control over the various tests. However I have struck an issue in trying to call the LFCLK when it is RC and getting the timers to work.

The Radio Test uses the HFCLK as well. When this is started I then try to start the LFCLK but at this point the app freezes.

I define the CLOCK_CONFIG_LF_SRC as RC

#define CLOCK_CONFIG_LF_SRC  0;

My lfclk config is

static void lfclk_config(void)
{
   uint32_t err_code = nrf_drv_clock_init();
   APP_ERROR_CHECK(err_code);

   nrf_drv_clock_lfclk_request(NULL);
    
   nrf_drv_clock_calibration_start(10 ,clock_handler);
}

I added the clock module to the sdk_config.h as follows

// <e> CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver
//==========================================================
#ifndef CLOCK_ENABLED
#define CLOCK_ENABLED 1
#endif
#if  CLOCK_ENABLED
// <o> CLOCK_CONFIG_XTAL_FREQ  - HF XTAL Frequency
 
// <0=> Default (64 MHz) 

#ifndef CLOCK_CONFIG_XTAL_FREQ
#define CLOCK_CONFIG_XTAL_FREQ 0
#endif

// <o> CLOCK_CONFIG_LF_SRC  - LF Clock Source
 
// <0=> RC 
// <1=> XTAL 
// <2=> Synth 

#ifndef CLOCK_CONFIG_LF_SRC
#define CLOCK_CONFIG_LF_SRC 0
#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 

#ifndef CLOCK_CONFIG_IRQ_PRIORITY
#define CLOCK_CONFIG_IRQ_PRIORITY 7
#endif

In lfclk_config() the err_code on init is 0. However it is nrf_drv_clock_lfclk_request() where I think it becomes unstuck. The code will run the next line or two but will stop fairly quickly. If nrf_drv_clock_lfclk_request() is not called, then the code runs but of course my timers or the app_button does not work but everything else does. I took a look at the documentation and the RTC example in the SDK but this seems to be based on there being an XTAL which I don't have. Presumably I am not configuring the source correctly, but any help would be appreciated.

EDITED: Added call stack png

radiotest.png

UPDATE: LFCLK appears to run initially but app_timer does not start

Having started the LFCLK I am now having an issue with app_timer_start() so something is not quite right yet. Looking at app_timer.c it seems to be hanging on timer_list_handler_sched(). Here is an image. This may be caused by the LFCLK stopping (possibly due to calibration not running?).

radiotest2.png

I got success for both app_timer_init() and app_timer_create() for this particular timer. I have never seen this issue when the LFCLK is started through the Soft Device.

Parents
  • I don't think the cal matters. Nor do I think the default HAL driver does any calibrations, the softdevice does do it automatically, but not the plain drivers.

    Richie the png made somewhere between little and no sense to me. I suggest stepping through the lf clock drivers and seeing what it sets the registers to. What I was expecting is that you start the lf clock and the driver waits for it to start, but because of a misconfiguration it never does, so it stays in the waiting for start loop forever.

Reply
  • I don't think the cal matters. Nor do I think the default HAL driver does any calibrations, the softdevice does do it automatically, but not the plain drivers.

    Richie the png made somewhere between little and no sense to me. I suggest stepping through the lf clock drivers and seeing what it sets the registers to. What I was expecting is that you start the lf clock and the driver waits for it to start, but because of a misconfiguration it never does, so it stays in the waiting for start loop forever.

Children
No Data
Related