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

Endless loop in "timer_list_remove"

Hi Nordic,

Chip set: nRF52840

SDK: 15.3.0

Softdevice: S140 (06.01.01)

Button interface with MCU: Total=13 (All with GPIOTE)

We have face one blocking issue at button press, some time it stuck at some point,


I have debugging the issue and found it stuck at "timer_list_remove" function.

also i haven't got any timer interrupt while this issue come.

/**@brief Function for removing a timer from the timer queue.
 *
 * @param[in]  timer_id   Id of timer to remove.
 *
 * @return     TRUE if Capture Compare register must be updated, FALSE otherwise.
 */
static bool timer_list_remove(timer_node_t * p_timer)
{
    timer_node_t * p_old_head;
    timer_node_t * p_previous;
    timer_node_t * p_current;
    uint32_t       timeout;

    // Find the timer's position in timer list.
    p_old_head = mp_timer_id_head;
    p_previous = mp_timer_id_head;
    p_current  = p_previous;

    while (p_current != NULL)
    {
        if (p_current == p_timer)
        {
            break;
        }
        p_previous = p_current;
        p_current  = p_current->next;
    }

    // Timer not in active list.
    if (p_current == NULL)
    {
        return false;
    }

    // Timer is the first in the list
    if (p_previous == p_current)
    {
        mp_timer_id_head = mp_timer_id_head->next;

        // No more timers in the list. Reset RTC1 in case Start timer operations are present in the queue.
        if (mp_timer_id_head == NULL)
        {
            NRF_RTC1->TASKS_CLEAR = 1;
            m_ticks_latest        = 0;
            m_rtc1_reset          = true;
            nrf_delay_us(MAX_RTC_TASKS_DELAY);
        }
    }

    // Remaining timeout between next timeout.
    timeout = p_current->ticks_to_expire;

    // Link previous timer with next of this timer, i.e. removing the timer from list.
    p_previous->next = p_current->next;

    // If this is not the last timer, increment the next timer by this timer timeout.
    p_current = p_previous->next;
    if (p_current != NULL)
    {
        p_current->ticks_to_expire += timeout;
    }

    return (p_old_head != mp_timer_id_head);
}

please give appropriate solution for that,

Thanks,

Sandip Divani

Related