Hello,
SDK : 16.0.0
Controller : NRF52840
I have 2 app_timer instance, one is used for longer sleep like 24 hours, and other is used to blink led when device is performing ble operation.
Device works perfectly 3 days approx led blinking stop and device behavior is unknown ,In log it is found that, rtc1 counter (value from app_timer_cnt_get()) is not incrementing.
APP_TIMER_DEF(Sip_timer); // Creates timer id for our program.
APP_TIMER_DEF(_1Sec_timer); //Create 1 sec timer id
void sec1_handler(void * p_context){
sec++;
static bool pinState=false;
//nrf_gpio_pin_toggle(STATUS_LED);
if(pinState){
pinState=false;
nrf_gpio_pin_clear(STATUS_LED);
app_timer_stop(_1Sec_timer);
ret_code_t err_code;
err_code = app_timer_start(_1Sec_timer, APP_TIMER_TICKS(3000L), NULL); //3000 ms= 3 sec
APP_ERROR_CHECK(err_code);
}
else{
pinState=true;
nrf_gpio_pin_set(STATUS_LED);
app_timer_stop(_1Sec_timer);
ret_code_t err_code;
err_code = app_timer_start(_1Sec_timer, APP_TIMER_TICKS(50L), NULL);
APP_ERROR_CHECK(err_code);
}
}
void timer_timeout_handler(void * p_context) //given time Sec timer handler
{
inSleep=0;
app_timer_stop(Sip_timer);
}
static void timers_init(void)
{
ret_code_t err_code = app_timer_init();
APP_ERROR_CHECK(err_code);
err_code = app_timer_create(&Sip_timer, APP_TIMER_MODE_REPEATED, timer_timeout_handler);
APP_ERROR_CHECK(err_code);
err_code = app_timer_create(&_1Sec_timer, APP_TIMER_MODE_REPEATED, sec1_handler);
APP_ERROR_CHECK(err_code);
}
static void application_timers_start(void) // sleep timer after timeout device will wakeup
{
ret_code_t err_code;
NRF_LOG_INFO("sleep for %d",sleepInterval);
err_code = app_timer_start(Sip_timer, APP_TIMER_TICKS(sleepInterval * 1000L), NULL); //1000 ms= 1 sec
APP_ERROR_CHECK(err_code);
}
static void led_timers_start(void)
{
ret_code_t err_code;
sec=0;
err_code = app_timer_start(_1Sec_timer, APP_TIMER_TICKS(1000L), NULL); //1000 ms= 1 sec
APP_ERROR_CHECK(err_code);
}
I have attached timer functions snippet .
Please help me regarding this.
Thank You
Bivay