Configure "configTICK_RATE_HZ"

anuradha123 wrote on Thursday, September 01, 2011:


I am using FreeRTOS with STM32L.

Currently I have configured “configTICK_RATE_HZ” parameter in FreeRTOSConfig.h to be 1000.
I want to change this parameter to 250.

There are  vTaskDelay()s and xTicksToWait defined in my code.
Is it possible to achieve the same delay miliseconds I achieved with Tick rate 1000 in Tick rate 250,
without changing the figures i used at vTaskDelay()s and  xTicksToWaits?

Thank you.

richard_damon wrote on Thursday, September 01, 2011:

If you wrote the delays as plain numbers, no. The key to making these delays “constant” over varying tick rates is to compute the value based on configTICK_RATE_HZ like    vTaskDelay(delayms * configTICK_RATE_HZ/1000)

I tend to define a macro to do the conversion and use it on all delays that are specified in ticks, so that I can specify them in ms and not need to worry if I adjust the tick rate.

There is one hack you could do if this is too much work to do it right, and that is change the tick interrupt to call the tick increment routine 4 times.

mikehitekp wrote on Thursday, September 01, 2011:

If these are defined in terms of portTICK_RATE_MS, defined in portmacro.h, then timings will still be correct.

If not they won’t, but it should be worth changing the definitions from (say) counts (in ticks) to delay_ms / portTICK_RATE_MS. If these are all constants, the compiler will work them out.


rtel wrote on Thursday, September 01, 2011:

Provided you keep configTICK_RATE_HZ at or below 1000, you can defined delays in milliseconds using:

5000 / portTICK_RATE_MS (for 5 seconds)
250 / portTICK_RATE_MS (for 250 milliseconds)

Then changing configTICK_RATE_HZ will not effect the delay period as portTICK_RATE_MS will be adjusted automatically.

There are lots and lots and lots of examples of this in the set of standard demo tasks that are used in all the demo applications included in the FreeRTOS download.


rtel wrote on Thursday, September 01, 2011:

Everybody answered at once ;o)

anuradha123 wrote on Friday, September 02, 2011:


Thanks for replying.