I’m using the vTaskGetRunTimeStats() function to get the % time for each task. I have 7 tasks running.
When I use that function called by Task1 I get this:
Hi
My Task1 does not take 100% of the time…
Task1 probably takes 5 or 10% of the absolute time. But I keep receiving 100% for Task1 and 0% for the others, but that’s impossible…
1000 is my tick rate in Hz, so the counter value will be 1000 / 10 = 100
I’ve read: “The run time statistics time base needs to have a higher resolution than the tick interrupt - otherwise the statistics may be too inaccurate to be truly useful. It is recommended to make the time base between 10 and 100 times faster than the tick interrupt.”
Ideally if you have a 1KHz tick you will need a time base of at least 10KHz. This can be achieved using a peripheral timer - you may even be able to hook into the timer used to generate the tick interrupts, then create a higher frequency timer by combining the number of overflows (which will be the number of tick interrupts) with the current timer value.
I’m not incrementing the ulTotalTime…I just showed on the code because it is an unsigned long, and therefore the value for that can’t ever be zero. And must always be at least above 100 ( for that /= 100UL; ).
But thank you for the suggestion Is there any example available how to hook into the timer generate the interrupt ticks as you said?