PERIODIC TIMER cannot be stopped in it's timer handler (cyw20719)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
NiLi_2861801
Level 3
Level 3
First like received First like given

Hi,

   Init a periodic timer, and start it.  but this timer cannot be stopped in it's timer handler.

1. init code

    /* Starting the app timer  */

    if ( wiced_init_timer(&app_timer, mesh_app_timer, 0, WICED_SECONDS_PERIODIC_TIMER) == WICED_SUCCESS)

    {

        if ( wiced_start_timer(&app_timer, MESH_APP_TIMEOUT_IN_SECONDS) != WICED_SUCCESS)

        {

            WICED_BT_TRACE(" APP START Timer FAILED!! \n");

        }

2.

void mesh_app_timer(uint32_t arg)

{

    WICED_BT_TRACE("mesh_app_timer: count:%d arg:%d\n", dev_ctx.app_timer_count, arg);   -> although stop timer returned successfully. this debug print still there.

    dev_ctx.app_timer_count++;

wiced_stop_timer(&app_timer);

#ifdef _DEB_PRINT_BUF_USE

    /* dump wiced bt buffer statistics on every 10 seconds to monitor buffer usage */

    if (!(dev_ctx.app_timer_count % _DEB_PRINT_BUF_USE))

    {

        _deb_print_buf_use();

    }

#endif

}

0 Likes
1 Solution
AbhishekK_31
Employee
Employee
10 sign-ins First comment on KBA 10 solutions authored

As a workaround, use a single shot timer instead of a periodic timer and restart the timer in the timer callback. This will act as a periodic timer and you can simply chose not to restart the timer if you want to stop it

View solution in original post

0 Likes
1 Reply