This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Infinite loop in osalFindTimer() in CC2541 TI BLE stack version 1.3.2

Other Parts Discussed in Thread: CC2541, BLE-STACK

Hi There,

I am using CC2541 with TI BLE stack version 1.3.2. In some cases after being connected to iPhone(not sure whether this is connection specific or random, but I am observing with iPhone) my device goes into infinite loop in function. It loops forever in while loop.

I have also attached a snapshot which says that srchTimer and srchTimer->next both points to same location and which is causing an infinite loop. Have anyone encountered the same issue anytime, if yes then what is the root cause of this?

/*********************************************************************
* @fn osalFindTimer
*
* @brief Find a timer in a timer list.
* Ints must be disabled.
*
* @param task_id
* @param event_flag
*
* @return osalTimerRec_t *
*/
osalTimerRec_t *osalFindTimer( uint8 task_id, uint16 event_flag )
{
osalTimerRec_t *srchTimer;

// Head of the timer list
srchTimer = timerHead;

// Stop when found or at the end
while ( srchTimer )
{
if ( srchTimer->event_flag == event_flag &&
srchTimer->task_id == task_id )
{
break;
}

// Not this one, check another
srchTimer = srchTimer->next;
}

return ( srchTimer );
}

  • Check if you keep using osal_start_timerEx to create too many timer? By the way, this is  ZigBee®, 6LoWPAN & 802.15.4 MAC Forum and I suggest you post your question at Bluetooth® Low Energy Forum.

  • Thanks YK for looking into this.

    I do not know but somehow I did not get any notification for your reply. I just saw your reply.

    My concern is that even I am allocating too many timers then at some instant TI framework should stop allocating events rather than creating an infinite loop. Have you ever faced any situation like this?

    Regards,
    Maulik
  • BLE-Stack won't stop timer event for you. You have to use osal_stop_timerEx to stop timer by yourself.

  • I understand your concern but when I say "even I am allocating too many timers then at some instant TI framework should stop allocating events rather than creating an infinite loop", what I mean is, say for example TI is able to allocate 100 timers(may not be the real figure, I am just taking for example) and I already allocated 100 timers by calling osal_start_timerEx, but I still need one more timer(101th) then I will again call osal_start_timerEx function and if TI is not having enough memory then it should not allocate this timer and should return with error, currently I am not checking for error codes received from this function but my concerns is anyways TI should not create an infinite loop, I am OK if it does not start a timer and return with error code, But I am not OK if it is causing an infinite loop which we can clearly see in image I uploaded above.

    I hope it is clear with you.

    Thanks,
    Maulik