How should I decide appropriate Tick time configTICK_RATE_HZ in RTOS project?

In STM32F4 project, I am using FreeRTOS. I am at initial phase of defining firmware design, I figured out there will be approximately 20-25 RTOS tasks running. FreeRTOS comes with default 1ms tick time which can be configured. So, on what basis should I decide appropriate Tick time for my system.
Solution:
As @Marvee Amasi and @techielew mentioned, you can consider so many things like the required level of real-time precision, power consumption, context switching overhead, and so on. But in most of the system, all tasks do not need a high level of time precision, and even its not just depend on tick but on overall firmware design, So I will suggest you to consider below things for your tick calculation and overall design. - Calculate approximate execution time of each task in milliseconds. If you have one/two time wise lengthy tasks with respect to execution time, please ignore them for Tick calculation. - Determine maximum acceptable latency for each task. - Trade off Tick time between least acceptable latency and the execution time of maximum number of tasks....
Jump to solution
6 Replies
Marvee Amasi
Marvee Amasi7mo ago
It's really just about finding a balance that meets your system's timing needs without creating unnecessary processing overhead. What I mean is that you should choose the tick time in your FreeRTOS system based on how quickly your tasks need to run. Okay now let's say if your tasks require fast response times, use a shorter tick time. If your tasks can have longer intervals, a longer tick time may be suitable. That's really how you could decide the correct "Tick time" for your system.
techielew
techielew7mo ago
Once you set the tick, that's the interrupt interval system-wide, so as @Marvee Amasi says you need to configure the tick to the fastest period required to measure each of your 20-25 tasks.
Solution
Umesh Lokhande
Umesh Lokhande6mo ago
As @Marvee Amasi and @techielew mentioned, you can consider so many things like the required level of real-time precision, power consumption, context switching overhead, and so on. But in most of the system, all tasks do not need a high level of time precision, and even its not just depend on tick but on overall firmware design, So I will suggest you to consider below things for your tick calculation and overall design. - Calculate approximate execution time of each task in milliseconds. If you have one/two time wise lengthy tasks with respect to execution time, please ignore them for Tick calculation. - Determine maximum acceptable latency for each task. - Trade off Tick time between least acceptable latency and the execution time of maximum number of tasks. - Try to keep high priority task’s execution time short. wherever possible use event based blocking. So the CPU will have more idle time. It increases responsiveness. - I assume pre-emption is enabled as it is in FreeRTOS default configurations . If you don’t want to do this all, keep Tick of 10 ms, and observe your system for responsiveness and performance. As per my experience 10 ms is a well balanced tick for most of the RTOS applications.
Swapnil
Swapnil6mo ago
Thanks for detailed response. Its really helpful.
Marvee Amasi
Marvee Amasi6mo ago
You are welcome
K_G_C
K_G_C6mo ago
i think it is also worth noting that when you set the tick time 1ms, the software timer resolution is 1ms. if your application needs <1ms timer you can use hardware timer or reduce the tick resolution.
Want results from more Discord servers?
Add your server
More Posts
pcb2blender - KiCad to Blender 3D model workflowThe pcb2blender tool revolutionizes the way KiCad projects are rendered in Blender. It streamlines tOptimizing color detection using Arduino and Color SensorHi all, I'm currently working on a project that requires accurate color detection, and I've integratDIY Transistor Radios: A Guide to Crafting High-Performance, Cost-Effective CircuitsDiscover the art of designing and constructing your own transistor radios with "Build Your Own TransFiveFlute Blogs - mechanical design resourceshttps://www.fiveflute.com/articles/ Mechaetronics and product design is something which I have beenImplementing Independent Speed Control for Dual DC Motors with Arduino and H-Bridge Motor Drivermorning ! I'm currently working on an Arduino project where I'm trying to control the speed and dirBuilding IoT solutions using open-sourceIs it possible to build a commercial IoT solution using open-source components? What options should 3 trends for 2024: edge intelligence, RISC-V, & chipletsThis article discusses three major technology trends expected to shape 2024: ➡️ Edge Intelligence EESP32 ESPAsyncWebServer - Server/Client CommunicationHello everyone, I have created a web server on an ESP32 and successfully established communication wTop Single Board Computers of 2023Some of the new boards that have hit the market in 2023: Raspberry Pi 4 Model B ROC-RK3588S-PC 8-Cthis is great, how long have you beenthis is great, how long have you been working on this