Unable to use uxTaskGetStackHighWaterMark - Compiler Error

chu13279 wrote on Monday, January 14, 2019:


I’m currently having issue trying to use uxTaskGetStackHighWaterMark to see smallest amount of remaining space after it has ran a task for the first time. I’m using GNU GCC Compiler and I did make some changes to FreeRTOSConfig.h to make it possible to use uxTaskGetStackHighWaterMark.

#define INCLUDE_uxTaskGetStackHighWaterMark     1

I have the task function defined as follows

#include "FreeRTOS.h"
#include "task.h"

UBaseType_t uxHighWaterMark;
UBaseType_t uxTaskGetStackHighWaterMark(TaskHandle_t xTask);

void bc_tspr(void * pvParameters);

void bc_tspr(void * pvParameters) {
    uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );

        // Data Integration Handler

        // Data Stacker Handler

        // Stacked Data Transmission Sector

        uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );

, and I create the task in the file as follows

extern void bc_tspr(void * pvParameters);
xTaskCreate(bc_tspr, "BEAM", 4000, NULL, task_prio_lvl_1, NULL);

However, even if I followed the example that I read in FreeRTOS Manual, it would generate compiler error as follows

undefined reference to `uxTaskGetStackHighWaterMark'
collect2: ld returned 1 exit status

It’d be really appreciated if someone could help solve this issue. Thanks in advance.

chu13279 wrote on Monday, January 14, 2019:


I rebuilt the project I was working from ground up again, and it still didn’t work with the option uxTaskGetStackHighWaterMark. On the other hand, I was able to achieve similar goal I was trying to make it out with vTaskList.

rtel wrote on Tuesday, January 15, 2019:

I’ve checked the .c file and setting INCLUDE_uxTaskGetStackHighWaterMark
to 1 is all that is required to make the function available.