Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

vTaskGetRunTimeStats on a Cortex M3 with IAR

Posted by Einar on July 27, 2010
Hi,

I am unable to make vTaskGetRunTimeStats() work on a Cortex M3 with IAR. First I followed the instructions in the FreeRTOS Reference Manual, but found that declaring the counting variable extern in FreeRTOSConfig.h gave a assembly error (in portasm.s) which I could not understand nor fix.

After declaring the variable in port.h (which I assume is not OK due to the license) I was able to get everything seemingly working. However, upon calling vTaskGetRunTimeStats(buffer) the buffer isn't filled. (I verified this by giving the first buffer bytes a known value before calling vTaskGetRunTimeStats()).

Does anybody know what I may be doing wrong?

RE: vTaskGetRunTimeStats on a Cortex M3 with IAR

Posted by James Stanley on July 29, 2010
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_STATS1

#ifdef INC_FREERTOS_H
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
#endif



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. */
ulHighFrequencyTimerTicks++;


You should now find that calling vTaskGetRunTimeStats() collects the required data.

RE: vTaskGetRunTimeStats on a Cortex M3 with IAR

Posted by Einar on July 30, 2010
Thank you for your advice jamesstanley. With that information it works like a charm.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS