I had the same problem on FreeRTOS and I found a solution. For portCONFIGURE_TIMER_FOR_RUN_TIME_STATS () and portGET_RUN_TIME_COUNTER_VALUE () I had configured timer 16bits with 20kHz frequency Now I have changed with 32bits timer and the problem is corrected.