The build error in portasm.s is due to the assembler trying to interpret the C keyword ‘extern’ which it can’t do. The trick is to include the extra code only when FreeRTOSConfig.h is included from FreeRTOS.h.
For the CORTEX_LM3Sxxxx_IAR_Keil demo, the code you need to add to FreeRTOSConfig.h is:
#define configGENERATE_RUN_TIME_STATS 1
extern volatile unsigned long ulHighFrequencyTimerTicks;
/* ulHighFrequencyTimerTicks is already being incremented at 20KHz. Just
set its value back to 0. */
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() ( ulHighFrequencyTimerTicks = 0UL )
#define portGET_RUN_TIME_COUNTER_VALUE() ulHighFrequencyTimerTicks
You will also need to add the following definition to timertest.c:
/* Counts the total number of times that the high frequency timer has 'ticked'.
This value is used by the run time stats function to work out what percentage
of CPU time each task is taking. */
volatile unsigned portLONG ulHighFrequencyTimerTicks = 0UL;
and add the following lines to the end of the function Timer0IntHandler():
/* Keep a count of the total number of 20KHz ticks. This is used by the
run time stats functionality to calculate how much CPU time is used by
each task. */
You should now find that calling vTaskGetRunTimeStats() collects the required data.