# FreeRTOS software timer not working 

**URL:** <https://forums.freertos.org/t/freertos-software-timer-not-working/6472>\
**Category:** Kernel\
**Created:** [April 4, 2017, 12:34pm UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472 "2017-04-04T12:34:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 4, 2017, 12:34pm UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/1 "2017-04-04T12:34:25Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Tuesday, April 04, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#b083):

Hi,  
FreeRTOS software timer is not calling the callback function and the timer is not running.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 4, 2017, 12:39pm UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/2 "2017-04-04T12:39:12Z")

</div>

**[dibosco](https://sourceforge.net/u/dibosco/)** wrote on [Tuesday, April 04, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#4803):

You’re going to have to give a _lot_ more information than that. Along the lines of (but not limited to):

Which version of FreeRTOS, which processor, which IDE, is this something you built yourself, is it stock FreeRTOS, what have you already tried?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 5, 2017, 6:32am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/3 "2017-04-05T06:32:59Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Wednesday, April 05, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#f7b2):

Hi,  
Version is FreeRTOS - 9.0.0-1, Atmega 32U4 processor, Arduino IDE, I have used FreeRTOS manual as a reference to build the timer.  
I have tried giving xTimerPeriod as 100/ portTICK\_PERIOD\_MS or just the delay in this case 100 and pdMS\_TO\_TICKS(100)  
I tried using xTimerStart( xTimer,0 ) as shown below apart from the standard method given in freertos manual.  
xTimer = xTimerCreate( “Timer1Min”,pdMS\_TO\_TICKS(5000),pdTRUE, (void\*) 0,prvTimerCallback);  
if( xTimer != NULL )  
{  
xTimerStart( xTimer,0 );  
}

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [April 5, 2017, 7:24am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/4 "2017-04-05T07:24:45Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Wednesday, April 05, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#9028):

Is the scheduler started?  
Can you confirm that your own tasks are running?  
And is the timer-task (“Tmr Svc”) running?  
Are all of your tasks blocking (sleeping) from time to time? If some task consumes all CPU time, the timer-task won’t get a chance to do its work. Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 5, 2017, 9:17am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/5 "2017-04-05T09:17:42Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Wednesday, April 05, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#caa1):

yeah scheduler is started. ihave given vTashScheduler() after the timer creation. All of my tasks are working according to their functionality.  
How to check whether all of my tasks are blocking time to time??

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 5, 2017, 9:40am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/6 "2017-04-05T09:40:03Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Wednesday, April 05, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#b097):

what is “Tmt Svc”?? i have not created any task with that name

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [April 5, 2017, 12:29pm UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/7 "2017-04-05T12:29:00Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Wednesday, April 05, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#800e):

If you would do a grep on the string “Tmr Svc”, you would see this line in timers.c :

```auto
    xReturn = xTaskCreate( prvTimerTask,
                           "Tmr Svc",
                           configTIMER_TASK_STACK_DEPTH,
                           NULL,
                           ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
                           &xTimerTaskHandle );

```

This task will be created automatically if `configUSE_TIMERS = 1`

This is an example of a non-blocking task:

```auto
void vMyTask( void *pvParameters )
{
    /* This task will not allow any other task to become active, except
    for tasks that have a higher priority than this one. */
    volatile int counter = 0;
    for( ;; )
    {
        counter++;
    }
    
}

```

A task can block (sleep) in many different ways, while waiting for a notification, an event group, a queue, a semaphore, and also while calling `vTaskDelay()` :

```
const TickType_t xTimeTicks = pdMS_TO_TICKS( 1000 );
for( ;; )
{
    /* Sleep for 1000 ms. */
    vTaskDelay( xTimeTicks );
    counter++;
}

```

Regards.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [April 5, 2017, 2:27pm UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/8 "2017-04-05T14:27:34Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, April 05, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#b097/822e):

[http://www.freertos.org/RTOS-software-timer.html](http://www.freertos.org/RTOS-software-timer.html)

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 6, 2017, 5:16am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/9 "2017-04-06T05:16:00Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Thursday, April 06, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#be48):

Hi,  
My configUSE\_TIMERS = 1, then my timer task will be created. still the callback function is not executed. with reference to ur explaination my tasks are not held up in blocked state.

PS: I am using Semaphore scheduling technique in my task. will it hinder the timer creation process.

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [April 6, 2017, 6:19am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/10 "2017-04-06T06:19:02Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Thursday, April 06, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#db99):

Would you mind sharing some of your code? It is difficult to assess from a distance why your timer-function wouldn’t be called. The easiest is to attach a ZIP file with the project you’re working on.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 6, 2017, 6:44am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/11 "2017-04-06T06:44:44Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Thursday, April 06, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#fb7e):

I have attaached some part of my code becoz of confidentiality issue with the company. Hope u can help me out with the timers

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 6, 2017, 6:58am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/12 "2017-04-06T06:58:58Z")

</div>

**[rtimenoob](https://sourceforge.net/u/rtimenoob/)** wrote on [Thursday, April 06, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#509e):

Hello,  
I did not watch your zip file but have you checked your configTIMER\_TASK\_PRIORITY? Maybe it is set too low.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 6, 2017, 7:31am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/13 "2017-04-06T07:31:24Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Thursday, April 06, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#f7bb):

hi,  
this is my configTIMER\_TASK\_PRIORITY  
#####define configTIMER\_TASK\_PRIORITY ( ( UBaseType\_t ) 3 )  
\*\*

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 6, 2017, 7:35am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/14 "2017-04-06T07:35:50Z")

</div>

**[rtimenoob](https://sourceforge.net/u/rtimenoob/)** wrote on [Thursday, April 06, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#386a):

Maybe your timer is just starving because its priority is too low.  
Maybe you could try it with this:  
#define configTIMER\_TASK\_PRIORITY ( configMAX\_PRIORITIES - 1 )

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 6, 2017, 7:42am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/15 "2017-04-06T07:42:02Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Thursday, April 06, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#751f):

okay… i will replace this and let you know about the updates

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [April 6, 2017, 9:01am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/16 "2017-04-06T09:01:53Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Thursday, April 06, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#8bde):

Your project will start 4 tasks:

Prio-1 : The task `TaskScanSwitch()` is **never blocking**.  
Prio-1 : The task `TaskSerial()` is **not blocking** , unless `Serial::available()` blocks, which I don’t think.  
Prio-3 : The task `TaskProcessSwitch()` blocks in a call to `xSemaphoreTake()`.  
Prio-1 : The task `TaskSerialConsole()` blocks in a call to `xSemaphoreTake()`.

With ‘blocking’ I mean ‘sleeping’, or refrain from using the CPU so that other tasks get a chance to run.

In some embedded RTOS projects, you will find a task that never blocks. It is given the lowest priority, often the “idle priority” ( tskIDLE\_PRIORITY ), in order to give priority to all other tasks.  
But it is more usual to let each task sleep ( block ) on a semaphore or any other blocking API. Especially when low power consumption becomes important.

I’m not sure if it is OK to call `xTimerCreate()` and `xTimerStart()` **before** the scheduler is started. Try to call these from within any of the running tasks.

There is a lot of excellent documentation about FreeRTOS, e.g. have a look [here](http://www.freertos.org/Documentation/RTOS_book.html).

The following items might be interesting to read about:

● Tasks and priorities  
● Pre-emption  
● Queues, Semaphores, and (recursive) Mutexes  
● Task notification  
● Event groups

I’m not sure what platform you’re using, but the easiest platform is probably the Windows simulation. You don’t need any special hardware for that.

Regards

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 10, 2017, 6:45am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/17 "2017-04-10T06:45:57Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Monday, April 10, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#386a/1654):

Hi,  
I made the changes as said by you, it didnt work

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [April 10, 2017, 7:35am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/18 "2017-04-10T07:35:52Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Monday, April 10, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#64fc):

> I made the changes as said by you, it didnt work

Does it work already? Did you find the problem?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 11, 2017, 6:44am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/19 "2017-04-11T06:44:36Z")

</div>

**[spoorthymb](https://sourceforge.net/u/spoorthymb/)** wrote on [Tuesday, April 11, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#f01f):

no it didnt, platform i am using is windows platform for simulation

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [April 11, 2017, 6:50am UTC](https://forums.freertos.org/t/freertos-software-timer-not-working/6472/20 "2017-04-11T06:50:58Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Tuesday, April 11, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/b05640b5/#abca):

If you’re able to pack (ZIP) your complete project, and attach it to a message, I could look at it and try it out. Regards.

[Next page](https://forums.freertos.org/t/freertos-software-timer-not-working/6472.md?page=2)
