I am using STM32L4+ microcontroller and FreeRTOS V10.0.1 kernel.
My STM32 is working with 118,784 MHz and the freertos with 1KHz (configTICK_RATE_HZ = 100)
I have to use the vTaskGetRunTimeStats() function in order to print rum time statistics, So I have configured and started the DWT counter, and get the CYCCNT value of the DWT register in the portGET_RUN_TIME_COUNTER_VALUE() function.
Note that the CYCCNT counter overruns every 36,15 seconds.
So at the 36 first seconds, vTaskGetRunTimeStats() function return correct statistic, but next, data are wrong (percentage time is more than 100%) .
In this ticket case, I noticed that I can add functions in order to clear runTimeStat usage :
But, I think that when I use this function to clear counter, statistic come wrong.
So my questions are :
- Should I use the vTaskClearUsage() API ?
if yes, this API should be called every time I called the vTaskGetRunTimeStats() function ? Or only when data come wrong.
In the vTaskClearUsage() function, the user have to re-configure the timer (DWT) by using vConfigureTimerForRunTimeStats();, So should I reconfigure the DWT ? Is it correct ?
- If not, What should I do when the percentage time come wrong ? Note that If I use a timer at a frequency of 10KHz (minimum recommended) I will also have the same problem, but later.