# Run Time Statistics for msp430 f5438

**URL:** <https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097>\
**Category:** Kernel\
**Created:** [July 11, 2012, 6:07pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097 "2012-07-11T18:07:42Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 11, 2012, 6:07pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/1 "2012-07-11T18:07:42Z")

</div>

**[modiallen](https://sourceforge.net/u/modiallen/)** wrote on [Wednesday, July 11, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#f7f7):

Hi everyone,  
i read the documentation about the Run Time Statistics, and i didnt understand everything about it.  
is there an already existing implemented timer for this macro portCONFIGURE\_TIMER\_FOR\_RUN\_TIME\_STATS(), or should i make it by my self and how to implement it.

because there is no example how to implement the timer for it.

Regards,  
Mhd

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 11, 2012, 6:33pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/2 "2012-07-11T18:33:02Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Wednesday, July 11, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#9646):

All you need is a time source that is fast enough. It has to be a lot faster than the tick interrupt for stats with a good resolution. How the time source is generated is very dependent on the peripherals that are available on your chip so you will need to configure that yourself.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 12, 2012, 12:44am UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/3 "2012-07-12T00:44:44Z")

</div>

**[modiallen](https://sourceforge.net/u/modiallen/)** wrote on [Thursday, July 12, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#b91e):

thank you for your reply.  
can you give me more details about how to implement this.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [July 12, 2012, 8:09am UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/4 "2012-07-12T08:09:07Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, July 12, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#784a):

We cannot provide support on using MSP430 specific hardware timers, but the macros and functions that need to be implemented, along with a couple of examples for other architectures, is provided here:

[http://www.freertos.org/rtos-run-time-stats.html](http://www.freertos.org/rtos-run-time-stats.html)

… although I presume you have seen that already.&nbsp; You can also search the FreeRTOS/Demo directory for other examples of where the macros portCONFIGURE\_TIMER\_FOR\_RUN\_TIME\_STATS and portGET\_RUN\_TIME\_COUNTER\_VALUE are used.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 13, 2012, 7:18pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/5 "2012-07-13T19:18:49Z")

</div>

**[modiallen](https://sourceforge.net/u/modiallen/)** wrote on [Friday, July 13, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#9629):

Hi Richard,  
my questions were not about the direct implementation. but i am asking to have more information than the information in the descrition.

like: where should the macro vTaskGetRunTimeStats() be called? in every task or only one time in one task and it will gather the statics about every other task?

from desciption in this site:&nbsp;&nbsp; [http://www.freertos.org/rtos-run-time-stats.html](http://www.freertos.org/rtos-run-time-stats.html)  
i understand that this macro must be used to configure the timer only but in the first example it was used to set the variable to 0 and the other macro portGET\_RUN\_TIME\_COUNTER\_VALUE to get the value of this variable. that is why, i am a little confused.

thanks for your reply.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [July 13, 2012, 7:38pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/6 "2012-07-13T19:38:12Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, July 13, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#1057):

> where should the macro vTaskGetRunTimeStats() be called?

That function is used to generate a human readable table of gathered run time stats.&nbsp; You can call it from any task that needs this information.&nbsp; It is normally used to output the information to a web server or console for viewing by the user.

> or only one time in one task and it will gather the statics about every other task?

vTaskGetRunTimeStats() does not gather the statistics, it only formats them into a human readable table.&nbsp; The kernel itself gathers the run time statistics if configGENERATE\_RUN\_TIME\_STATS is set to 1.&nbsp; If configGENERATE\_RUN\_TIME\_STATS is set to one then the kernel tries to call portCONFIGURE\_TIMER\_FOR\_RUN\_TIME\_STATS() once during start up, then portGET\_RUN\_TIME\_COUNTER\_VALUE() on each task switch.&nbsp; That is why you have to define the portCONFIGURE\_TIMER\_FOR\_RUN\_TIME\_STATS() portGET\_RUN\_TIME\_COUNTER\_VALUE() to do the right thing for your hardware (you define them, but you don’t call them, the kernel calls them).

> i understand that this macro must be used to configure the timer only but in the first example it was used to set the variable to 0 and the other macro portGET\_RUN\_TIME\_COUNTER\_VALUE to get the value of this variable. that is why, i am a little confused.

vTaskGetRunTimeStats() does not set anything to zero, in the example portCONFIGURE\_TIMER\_FOR\_RUN\_TIME\_STATS() sets a variable to zero (for that particular implementation) because it is called once at start up it does the initialisation.&nbsp; The other macro returns the value because it is called during a context switch to return the current time value.

Hope that helps.  
Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 13, 2012, 9:18pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/7 "2012-07-13T21:18:01Z")

</div>

**[ulmus71](https://sourceforge.net/u/ulmus71/)** wrote on [Friday, July 13, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#e0aa):

modiallen, it is so simple…&nbsp; vTaskGetRunTimeStats() is called once if you want have stats.  
portGET\_RUN\_TIME\_COUNTER\_VALUE must return counter value that is 10 to 100 quicket than FreeRTOS ticks. In example on the site you mentioned is a timer register, thats why it is just variable simple macro. In my implementation it is a variable too, but in configure function i am configuring hardware timer which increment that variable with proper frequency, to get good stats…

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 13, 2012, 9:34pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/8 "2012-07-13T21:34:21Z")

</div>

**[ulmus71](https://sourceforge.net/u/ulmus71/)** wrote on [Friday, July 13, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#f1c6):

Sorry for my answer, link to post showed me only one post 😃 i havent seen your answers:)🙂

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 14, 2012, 1:03am UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/9 "2012-07-14T01:03:09Z")

</div>

**[modiallen](https://sourceforge.net/u/modiallen/)** wrote on [Saturday, July 14, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#7c86):

thank you a lot richard. now i got it.  
i implemented it like this:  
i implement a timer that will cause an interrupt 10 times faster than the interrupt from the scheduler. and increment a variable every time this interrupt occured. and the macro&nbsp; portGET\_RUN\_TIME\_COUNTER\_VALUE only return the value of this variable.

i think now it must work. but i am getting nonreasnoble stats now.  
all tasks have the absolut time “u” or the percentage values “u” %.  
what does this “u” mean here?

ulmus, thank you for your answer.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 18, 2012, 8:54pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/10 "2012-07-18T20:54:52Z")

</div>

**[modiallen](https://sourceforge.net/u/modiallen/)** wrote on [Wednesday, July 18, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#4426):

Hi,  
as i told the last time, the Statistics, that i am getting are only “u”&nbsp; for almost every task except the idle task.  
what does this “u” mean? undefined?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 18, 2012, 9:11pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/11 "2012-07-18T21:11:28Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Wednesday, July 18, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#6e18):

It probably just means that your C library does not understand the %u format specifier, so just prints the u out. Look at the code:

```
						#ifdef portLU_PRINTF_SPECIFIER_REQUIRED
						{
							sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage );							
						}
						#else
						{
							/* sizeof( int ) == sizeof( long ) so a smaller
							printf() library can be used. */
							sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );
						}
						#endif
```

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 18, 2012, 9:12pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/12 "2012-07-18T21:12:50Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Wednesday, July 18, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#29a2):

Try again with different formatting:

```
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED
{
    sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", 
            pxNextTCB->pcTaskName, 
            pxNextTCB->ulRunTimeCounter, 
            ulStatsAsPercentage );                            
}
#else
{
    /* sizeof( int ) == sizeof( long ) so a smaller
    printf() library can be used. */
    sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t%u%%\r\n", 
            pxNextTCB->pcTaskName, 
            ( unsigned int ) pxNextTCB->ulRunTimeCounter, 
            ( unsigned int ) ulStatsAsPercentage );
}
#endif
```

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 2, 2012, 6:16pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430-f5438/3097/13 "2012-08-02T18:16:52Z")

</div>

**[modiallen](https://sourceforge.net/u/modiallen/)** wrote on [Thursday, August 02, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/8817a9ad/#3de2):

hey,  
thank you for your reply.  
the compiler must be configured to support printf to get the values. but i cannot do it due to the limited size that i have now in my application. i am reading it manually with the support of breakpoints.
