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

stop and start timer bug

Hi all,

i'm using an app_timer. I need to use three timer for debounce of three button. In my case i have to discriminate the push of three button at same time. When all three buttons has release, my FSM sends an event (ALL_THREE_BUTTON_IS RELEASE).

This is my ButtonHandel:

   static void BUTTON_EventHandler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
       uint32_t err_code;
       BTN_Id_t lIdButton;


   
   switch (pin)
   {
      case BTN_CENTRAL_PIN:
         lIdButton = BTN_CENTRAL;
         err_code = TIMER_Stop(TIMER_BTN_DEBOUNCE_BUTTON_3);
         err_code = TIMER_Stop(TIMER_BTN_DEBOUNCE_BUTTON_2);
         err_code = TIMER_Stop(TIMER_BTN_DEBOUNCE_BUTTON_1);
         APP_ERROR_CHECK(err_code);
         err_code = TIMER_Start(TIMER_BTN_DEBOUNCE_BUTTON_1,TIMER_DEBOUNCE_DELAY,(void*)lIdButton);   
         APP_ERROR_CHECK(err_code);

         break;

      case BTN_SIDE_1_PIN:
         lIdButton = BTN_SIDE_1;
         err_code = TIMER_Stop(TIMER_BTN_DEBOUNCE_BUTTON_3);
         err_code = TIMER_Stop(TIMER_BTN_DEBOUNCE_BUTTON_2);
         err_code = TIMER_Stop(TIMER_BTN_DEBOUNCE_BUTTON_1);
         APP_ERROR_CHECK(err_code);
         err_code = TIMER_Start(TIMER_BTN_DEBOUNCE_BUTTON_2,TIMER_DEBOUNCE_DELAY,(void*)lIdButton);   
         APP_ERROR_CHECK(err_code);
         break;

      case BTN_SIDE_2_PIN:
         countrelese++;
         lIdButton = BTN_SIDE_2;
         err_code = TIMER_Stop(TIMER_BTN_DEBOUNCE_BUTTON_3);
         err_code = TIMER_Stop(TIMER_BTN_DEBOUNCE_BUTTON_2);
         err_code = TIMER_Stop(TIMER_BTN_DEBOUNCE_BUTTON_1);
         APP_ERROR_CHECK(err_code);
         nrf_delay_ms(10);
         err_code = TIMER_Start(TIMER_BTN_DEBOUNCE_BUTTON_3,TIMER_DEBOUNCE_DELAY,(void*)lIdButton);   
         APP_ERROR_CHECK(err_code);      
         break;

      default:
         break;
   }

}

So when a last button was release, a timer debounce starts and check if all three buttons was release. But sometimes, the callback of this timer debounce not expire. But the err_code = TIMER_Start(TIMER_BTN_DEBOUNCE_BUTTON_3,TIMER_DEBOUNCE_DELAY,(void*)lIdButton); is called, but don't wxpire.

It's possible that app_timer.h library have a bug releated to STOP and START the same Timer?

Thanks, Anna

Parents Reply Children
No Data
Related