I am using app_timer to measure the time taken to execute a function. I am using ble_app_template code. As mentioned in the documentation, app_timer needs to initialize the LFCLK. It doesn't need to initialize a LFCLK if softdevice is used. But in the template, timer is created even before initialization of LFCLK. LFCLK is initialized in the ble_stack_init() which is after the timers_init() function.
-
Why is the timer working even without initializing LFCLK ?
Source code is present here : github.com/.../silver-umbrella
These are the code snippets :
int main(void) { uint32_t err_code; bool erase_bonds; err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); timers_init(); buttons_leds_init(&erase_bonds); ble_stack_init(); timeslot_sd_init(); peer_manager_init(erase_bonds); if (erase_bonds == true) { NRF_LOG_INFO("Bonds erased!\r\n"); } gap_params_init(); advertising_init(); application_timers_start(); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // This is my function cal_RPA_gen_time(); for (;;) { if (NRF_LOG_PROCESS() == false) { power_manage(); } } } static void application_timers_start(void) { uint32_t err_code; //starting timer for 100 secs err_code = app_timer_start(m_app_timer_id, APP_TIMER_TICKS(100000, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code); SEGGER_RTT_printf(0, "Timer Started\n\n"); }
-
If I call the function timers_init() after ble_stack_init(), timer is not started (no output on RTT viewer). Why ?
-
If I decrease the advertising interval to less than 20 ms i.e. min advertising interval, I get this kind of output for infinite time :
0> Timer Created 0> Timer Created 0> Timer Created 0> Timer Created 0> Timer Created 0> Timer Created 0> Timer Created 0> Timer Created 0> Timer Created 0> Timer Created 0> Timer Created
Is there any relation between advertising module and RTC1 ?
-
Also, when I try to set the gap address when timer is running, I am getting undesired output on RTT viewer. It seems like the timer get restarted when a new address is set. Why ?
This is the desired output :
This is the ouput I am getting :
Thanks in advance.