# Run Time Statistics for MSP430FR6989

**URL:** <https://forums.freertos.org/t/run-time-statistics-for-msp430fr6989/22659>\
**Category:** Kernel\
**Created:** [February 28, 2025, 5:50pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430fr6989/22659 "2025-02-28T17:50:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![w3marshall](https://avatars.discourse-cdn.com/v4/letter/w/c2a13f/32.png) [@w3marshall](https://forums.freertos.org/u/w3marshall)\
**Post date:** [February 28, 2025, 5:50pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430fr6989/22659/1 "2025-02-28T17:50:22Z")

</div>

Hello, I downloaded FreeRTOS 202212.01 and used the MSP430X\_MSP430FR5969\_LaunchPad\_IAR\_CCS Demo to get things working on my MSP430FR6989 using Code Composer Studio v12. Everything seems to work except my run time stats return “u%” for some of the percent times and “u” for all the absolute times (See image below). anyone have any idea what might be going on here and can point me in the right direction. Also, this is my first time posting so forgive me if I didn’t follow the forum etiquette.

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/3/321faa317b39a78ffefa97410edfc3008bbfab81.png)

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [February 28, 2025, 6:24pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430fr6989/22659/2 "2025-02-28T18:24:08Z")

</div>

Look at the code that is printing that result. if it is using a printf variant, perhaps the format string got messed up.

---

<div class="post-metadata">

**Author:** ![w3marshall](https://avatars.discourse-cdn.com/v4/letter/w/c2a13f/32.png) [@w3marshall](https://forums.freertos.org/u/w3marshall)\
**Post date:** [February 28, 2025, 7:04pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430fr6989/22659/3 "2025-02-28T19:04:23Z")

</div>

Okay, after digging through the files, I found `sprintf()` in the function `vTaskGetRunTimeStats()` in tasks.c file. I think this is where the format is getting messed up:

```C
 if( ulStatsAsPercentage > 0UL )
                    {
                        #ifdef portLU_PRINTF_SPECIFIER_REQUIRED
                        {
                            sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[x].ulRunTimeCounter, ulStatsAsPercentage );
                        }
                        #else
                        {
                            /* sizeof( int ) == sizeof( long ) so a smaller
                             * printf() library can be used. */
                            sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[x].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */
                        }
                        #endif
                    }
                    else
                    {
                        /* If the percentage is zero here then the task has
                         * consumed less than 1% of the total run time. */
                        #ifdef portLU_PRINTF_SPECIFIER_REQUIRED
                        {
                            sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\r\n", pxTaskStatusArray[x].ulRunTimeCounter );
                        }
                        #else
                        {
                            /* sizeof( int ) == sizeof( long ) so a smaller
                             * printf() library can be used. */
                            sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[x].ulRunTimeCounter ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */
                        }
                        #endif
                    }

```

I removed the `#define portLU_PRINTF_SPECIFIER_REQUIRED` definition in the portmacro.h file and the console output now looks like this:

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/e/e3a8849c4bdc9b709d21e9f709c66fd774f79d79.png)

---

<div class="post-metadata">

**Author:** ![w3marshall](https://avatars.discourse-cdn.com/v4/letter/w/c2a13f/32.png) [@w3marshall](https://forums.freertos.org/u/w3marshall)\
**Post date:** [February 28, 2025, 7:06pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430fr6989/22659/4 "2025-02-28T19:06:41Z")

</div>

Thanks for the help @richard-damon . Do you know why this fixed things? Does the compiler not understand the `%lu` format specifer?

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [February 28, 2025, 7:20pm UTC](https://forums.freertos.org/t/run-time-statistics-for-msp430fr6989/22659/5 "2025-02-28T19:20:35Z")

</div>

It may be your C library doesn’t understad %lu and that is causing the errors.
