Hello,
I have a question. I am creating 8 timers on certain events. These timers have the same callback function. The problem is that when I delete the 7 every thing works fine. But as soon as I delete the 8 it returns pdFAIL.
What could be the reason. Please explain
Another strange thing that I have observed is that when I create three timers, sometimes it deletes all the timers and sometimes it deletes only two. Is this has to do something with timer command queue
Can you please post an example of how you are creating the timers - the minimum amount of source code that exhibits this behaviour. Also, what is the priority of the timer service task relative to other tasks in your application - especially relative to the priority of the task that is creating and deleting the timers.
The priority of the timer service task is 5. The priority of other tasks is less than the timer service task.
Following is the code to create the timer.
void create_initial_activity_timer(int id)
{
const TickType_t xTicksToWait = pdMS_TO_TICKS(DOIP_INITIAL_ACTIVITY_TIMER_PERIOD);
// Create a one-shot timer
TimerHandle_t one_shot_timer;
BaseType_t xTimer1Started;
one_shot_timer=xTimerCreate(
/* Text name for the software timer - not used by FreeRTOS. */
"Initial",
/* The software timer's period in ticks. */
xTicksToWait,
/* Setting uxAutoRealod to pdFALSE creates a one-shot software timer. */
pdFALSE,
/* This example does not use the timer id. */
(void*)id,
/* The callback function to be used by the software timer being created. */
vTimerCallBackinitial);
if(one_shot_timer != NULL)
{
xTimer1Started=xTimerStart(one_shot_timer, 0 );
//Start the one shot timer
if( ( xTimer1Started == pdPASS ))
{
printf("Timer created for id %d",id);
}
}
}
Following is the code, that represents a timer call back function.
I changed the configTIMER_QUEUE_LENGTH from 10 to 50,
It started to work fine.
Is it possible that configTIMER_QUEUE_LENGTH didnt had the enough space to process xTimerDelete() function call?
If some of your timer call back block (or spend a long time) and keep the timer service task from running and draining the queue this could happen, Remember that the timer call backs run under the timer task, so while they are doing their actions, there isn’t anyway to service requests in the queue.