How to use Timer in FreeRTOS?

mrasool wrote on Thursday, May 15, 2008:

Hi all,

I have read other threads on using timers in FreeRTOS, and I have tried to use vApplicationTickHook. I have made a global variable "time_ticks" which is incremented on every call to vApplicationTickHook, But as I run the code, this hook is only triggered when my task is doing nothing, i.e when I call vTaskDelay. This means that I can only count the ticks of delay of a task. But I need a timer, e.g. I want to calculate how much time is taken by a particular code to run. So i want to save some timer value before starting the task, and then get the value of elapsed time after the task has finished its work.

How can I do it in FreeRTOS? Like in TinyOS, there is Timer module, and you can start a timer and stop it and take its value at any point of time.

Immediate response will be highly appreciated!

Thanks in advance,


rtel wrote on Thursday, May 15, 2008:

I can send you the timer module donated by Neil.  If you would like a copy send me an email to r _dot barry {at}

Alternatively you can make uxTickCount global (provided you are using a 32bit port and uxTickCount is 32 bits, or you are using a 16 bit port and uxTickCount is 16bits] to give you access to the tick interrupt count.