# Errors when configuring run time counter on xilinx microblaze port

**URL:** <https://forums.freertos.org/t/errors-when-configuring-run-time-counter-on-xilinx-microblaze-port/9445>\
**Category:** Xilinx\
**Created:** [April 6, 2020, 10:23pm UTC](https://forums.freertos.org/t/errors-when-configuring-run-time-counter-on-xilinx-microblaze-port/9445 "2020-04-06T22:23:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nhmkmhyh](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/nhmkmhyh/32/163_2.png) [@nhmkmhyh](https://forums.freertos.org/u/nhmkmhyh)\
**Post date:** [April 6, 2020, 10:23pm UTC](https://forums.freertos.org/t/errors-when-configuring-run-time-counter-on-xilinx-microblaze-port/9445/1 "2020-04-06T22:23:46Z")

</div>

Hello,

I have an application using freeRTOS xilinx microblaze port. I just tried to enable run time stats but I am getting errors about defining portGET\_RUN\_TIME\_COUNTER\_VALUE & portCONFIGURE\_TIMER\_FOR\_RUN\_TIME\_STATS even though I DO have them defined in my main file as shown below

```
extern XTmrCtr xTickTimerInstance;
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() dummy()
#define portGET_RUN_TIME_COUNTER_VALUE() XTmrCtr_GetValue(&xTickTimerInstance, 1UL)

```

I have had this feature working on other ports and I am doing the same exact thing. I am not sure why I am getting these errors. Any thoughts?

BTW I have a dumy function for portCONFIGURE\_TIMER\_FOR\_RUN\_TIME\_STATS() because the run timer counter in this port is setup in vApplicationSetupTimerInterrupt when the tick counter is initialized so I believe no additional setup is needed.

---

<div class="post-metadata">

**Author:** ![nhmkmhyh](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/nhmkmhyh/32/163_2.png) [@nhmkmhyh](https://forums.freertos.org/u/nhmkmhyh)\
**Post date:** [April 6, 2020, 10:36pm UTC](https://forums.freertos.org/t/errors-when-configuring-run-time-counter-on-xilinx-microblaze-port/9445/2 "2020-04-06T22:36:28Z")

</div>

So I was able to get rid off these specific errors by including the definition section mentioned above in FreeRTOSConfig.h config file instead of main.

However, now I get an error saying undefined reference to `vTaskGetRunTimeStats’. I thought once I make those definitions as well as defining configUSE\_STATS\_FORMATTING\_FUNCTIONS to 1, then I will be able to use this function. Not sure what I am missing. Please keep in mind that function vTaskList() works fine.

I also noticed that the #if ( configGENERATE\_RUN\_TIME\_STATS == 1 ) conditional section defined within vTaskSwitchContext( void ) in task.h is still highlighted grey even though I have configGENERATE\_RUN\_TIME\_STATS defined as 1. Not sure why.

---

<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:** [April 7, 2020, 1:37am UTC](https://forums.freertos.org/t/errors-when-configuring-run-time-counter-on-xilinx-microblaze-port/9445/3 "2020-04-07T01:37:45Z")

</div>

Do you also have configSUPPORT\_DYNAMIC\_ALLOCATION set to 1? See [https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/master/tasks.c#L4478](https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/master/tasks.c#L4478)

---

<div class="post-metadata">

**Author:** ![bhill](https://avatars.discourse-cdn.com/v4/letter/b/a698b9/32.png) [@bhill](https://forums.freertos.org/u/bhill)\
**Post date:** [May 19, 2020, 5:15pm UTC](https://forums.freertos.org/t/errors-when-configuring-run-time-counter-on-xilinx-microblaze-port/9445/4 "2020-05-19T17:15:00Z")

</div>

Hi. I’m trying to do the same thing, trying to access the functionality provided by defining configGENERATE\_RUN\_TIME\_STATS. Trying to follow the info here: [https://www.freertos.org/rtos-run-time-stats.html](http://rtos-run-time-stats). Found your question and it looks like your solution is exactly what I was looking for. However, How did you get FreeRTOSConfig.h to recognize XTmrCtr type? I tried including xtmrctr.h but that just resulted in a bazillion errors. I’m guessing it messed up the include structure?

---

<div class="post-metadata">

**Author:** ![nhmkmhyh](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/nhmkmhyh/32/163_2.png) [@nhmkmhyh](https://forums.freertos.org/u/nhmkmhyh)\
**Post date:** [May 29, 2020, 9:34pm UTC](https://forums.freertos.org/t/errors-when-configuring-run-time-counter-on-xilinx-microblaze-port/9445/5 "2020-05-29T21:34:26Z")

</div>

Not sure if you already solved this but just saw it. The way I was able to get it to work is to declare a function in main that handle XTmrCtr and then reference it in FreeRTOSConfig.h. I did not even need to add an extern deceleration in FreeRTOSConfig.h. Not sure how the linker resolve it but it works. Here is more details.

in main.c:

```
#include "xtmrctr.h"
extern XTmrCtr xTickTimerInstance;
unsigned int getRunTimeCount(){
    return XTmrCtr_GetValue(&xTickTimerInstance,1UL);
}

```

in FreeRTOSConfig.h:

```
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portGET_RUN_TIME_COUNTER_VALUE() getRunTimeCount()

```

Hope that helps!
