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

Stop and restart APP_TIMER doesn't work with SDK12

I use an app_timer to periodically update sensor reading in my application. There is a characteristic used to change updating rate by stopping and restarting the app_timer:

app_timer_stop(m_our_char_timer_id);
app_timer_start(m_our_char_timer_id, APP_TIMER_TICKS(1000, APP_TIMER_PRESCALER), NULL); //1000ms
			

It works fine with SDK11. But with SDK12, I couldn't receive any data package after stopping and restarting the app_timer. Weird thing is, usually after 5 to 6 minutes, it resumes updating again.

Any help is appreciated. Thanks.

Parents
  • I started a new project with SDK12 and copied lines from the project with SDK11. Here are the lines related to app_timer in my project.

    APP_TIMER_DEF(m_our_char_timer_id);
    #define OUR_CHAR_TIMER_INTERVAL     APP_TIMER_TICKS(100, APP_TIMER_PRESCALER)
    
    static void timer_timeout_handler(void * p_context)
    {
          flag = true;
    }
    
    static void timers_init(void)
    {
               APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
               app_timer_create(&m_our_char_timer_id, APP_TIMER_MODE_REPEATED, timer_timeout_handler);
     }
    
     static void application_timers_start(void)
     {
            app_timer_start(m_our_char_timer_id, OUR_CHAR_TIMER_INTERVAL, NULL);
      }
    
     int main(void)
     {
                timers_init();
                application_timers_start();
      }
    
Reply
  • I started a new project with SDK12 and copied lines from the project with SDK11. Here are the lines related to app_timer in my project.

    APP_TIMER_DEF(m_our_char_timer_id);
    #define OUR_CHAR_TIMER_INTERVAL     APP_TIMER_TICKS(100, APP_TIMER_PRESCALER)
    
    static void timer_timeout_handler(void * p_context)
    {
          flag = true;
    }
    
    static void timers_init(void)
    {
               APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
               app_timer_create(&m_our_char_timer_id, APP_TIMER_MODE_REPEATED, timer_timeout_handler);
     }
    
     static void application_timers_start(void)
     {
            app_timer_start(m_our_char_timer_id, OUR_CHAR_TIMER_INTERVAL, NULL);
      }
    
     int main(void)
     {
                timers_init();
                application_timers_start();
      }
    
Children
No Data
Related