Timer Task Not Starting


I am working on creating a countdown timer using xTimerCreateStatic.

xTimer = xTimerCreateStatic(
                      &xTimerBuffer ); 

Time config is set to 1 as well as static allocation, so everything should be working fine. I am running numerous tasks and I am able to run a timer in my main when I start the scheduler. I am also able to have a working timer in the init task functions I have. However, when I try to create a timer and start it in one of my tasks, the callback is never reached. When I check the expiry time after starting the timer it is always 0 for some reason. I checked if the timer was running with xTimerIsTimerActive and it returns false. When I run (xTimerStart( xTimer , 1000 ) != pdPASS) , it never returns a failure and when I step through the timer.c file create functions it seems to be working properly. I do not have much freeRtos experience and kind of stuck. I am only trying to use one countdown timer in this task.

Test function I am using:

 for( ;; ) {
         if( xTimerIsTimerActive(xAssocTimer) == pdFALSE) {
           for(;;); /* failure!?! */
           xRemainingTime = xTimerGetExpiryTime( xTimer ) - xTaskGetTickCount();

static void vTimerCallback( TimerHandle_t xTimer )
    int i = 1;  //jsut setting a break here

Is it possible the timer task is getting starved of execution by higher priority tasks? Try setting its priority to (configMAX_PRIORITIES - 1) - which is the highest in the system.

Thank you for the response. I thought that was the case so I have tried doing that. It still never gets activated.

The subject of your post I that the timer task is not starting, but the text of the post suggests it is just the timer that is not running. Can you confirm the timer task is actually starting.

Ok it seems that I did not actually set the priority of the task correctly to (configMAX_PRIORITIES - 1). That solution worked. I had made that change previously but I may have lost/undone them. Thank you for the help! The timer is now active and working.