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

Events in App_button cause endless loop

I use app_button with simple handle function. When button is pressed the led is on, when released the led is off. Everything works fine, but after some random number button is pressed, the system go in an endless loop and nothing works anymore. The loop is in the timer_timeouts_check() function:

    // Expire all timers within ticks_elapsed and collect ticks_expired.
    while (p_timer != NULL)
    {
        // Do nothing if timer did not expire.
        if (ticks_elapsed < p_timer->ticks_to_expire)
        {
            break;
        }

        // Decrement ticks_elapsed and collect expired ticks.
        ticks_elapsed -= p_timer->ticks_to_expire;
        ticks_expired += p_timer->ticks_to_expire;

        // Move to next timer.
        p_previous_timer = p_timer;
        p_timer = p_timer->next;

        // Execute Task.
        if (p_previous_timer->is_running)
        {
            p_previous_timer->is_running = false;
            timeout_handler_exec(p_previous_timer);
        }
    }

I don't use Softdevice, I am using SDK12.1.0 and have a custom board. What can I do?

Parents
  • I only initialize the timer module with

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    

    then I initialize and enable a button with functions from app_button library:

    app_button_init((app_button_cfg_t *)app_buttons, BUTTONS_NUMBER,
                              APP_TIMER_TICKS(30, APP_TIMER_PRESCALER));
    app_button_enable();
    

    A button is defined as:

    static const app_button_cfg_t app_buttons[BUTTONS_NUMBER] =
            { {BUTTON_nLASER, false, BUTTON_PULL, bsp_button_event_handler}};
    

    and the button handler function is defined as:

    static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action)
    {
    	switch (button_action)
    	{
    		case APP_BUTTON_PUSH:	
          LEDS_ON(LED_RGB_RED_MASK);			
    			break;
    		case APP_BUTTON_RELEASE:
    			LEDS_OFF(LED_RGB_RED_MASK);	
    			break;
    	}
    }
    

    I don't use timers. The timers are used automatically in app_button library which is part of SDK.

Reply
  • I only initialize the timer module with

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    

    then I initialize and enable a button with functions from app_button library:

    app_button_init((app_button_cfg_t *)app_buttons, BUTTONS_NUMBER,
                              APP_TIMER_TICKS(30, APP_TIMER_PRESCALER));
    app_button_enable();
    

    A button is defined as:

    static const app_button_cfg_t app_buttons[BUTTONS_NUMBER] =
            { {BUTTON_nLASER, false, BUTTON_PULL, bsp_button_event_handler}};
    

    and the button handler function is defined as:

    static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action)
    {
    	switch (button_action)
    	{
    		case APP_BUTTON_PUSH:	
          LEDS_ON(LED_RGB_RED_MASK);			
    			break;
    		case APP_BUTTON_RELEASE:
    			LEDS_OFF(LED_RGB_RED_MASK);	
    			break;
    	}
    }
    

    I don't use timers. The timers are used automatically in app_button library which is part of SDK.

Children
No Data
Related