I’m an advanced user of the FreeRTOS, however, I can’t seem to reset the runtime counters. Resetting the counters is important in applications where the tasks are resumed or suspended upon events so you can measure runtime stats during IDLE and LOAD conditions separately.
I modified vTaskGetRunTimeStats() which takes a boolean to reset the counters, and prvGenerateRunTimeStatsForTasksInList() resets the ulRunTimeCounter for each task based on this boolean variable. Then at the end of vTaskGetRunTimeStats(), it resets the ulTempCounter and the high-frequency hardware timer values to zero before returning.
It all seems to be working well for all tasks, except for the task that is calling vTaskGetRunTimeStats. Somehow, the task calling the function ends up having a rather corrupt value of its ulRunTimeCouter even though the ulRunTimeCounter was reset. I am using interrupt driven serial communication so the task calling vTaskGetRunTimeStats() is not getting blocked while delivering UART data, it suspends immediately after calling vTaskGetRunTimeStats(). Upon entry to vTaskGetRunTimeStats(), the scheduler is suspended, so it should not add anything to ulRunTimeCounter of any task. sprintf should concatenate the data and when vTaskGetRunTimeStats() exits, before resuming the scheduler, all counters should be zero… but somehow something appears to be wrong somewhere…
Any hints anyone? Richard? I am willing to help implement this method for future versions and it is almost done, except for the issue mentioned above. Source code is well organized too and I only added one more macro other than boolean parameter to vTaskGetRunTimeStats(): portRESET_RUN_TIME_COUNTER()
Thanks in advance,