Quality RTOS & Embedded Software

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


Loading

uxTaskGetStackHighWaterMark problem?

Posted by graham clark on October 19, 2008
Hi, I'm using FreeRTOS 5.0.3 on a PIC32 and just I've started to use uxTaskGetStackHighWaterMark() to determine my stack usage. However I'm getting some strange values returned from it. As far as I can see it should return the number of words available on the stack. On the PIC32 a word is 4 bytes. Looking at the code it seems to return the number of 16byte words remaining!

while( *pucStackByte == tskSTACK_FILL_BYTE )
{
pucStackByte -= portSTACK_GROWTH;
usCount++;
}

usCount /= sizeof( portSTACK_TYPE );

return usCount;

posSTACK_GROWTH is set to -4 by FreeRTOS, so the pointer moves from low to high memory couting 4 bytes at a time until a byte indicating stack has been used.

This is OK but then it adjusts the counter by dividing by 4 and returning this. This appears to be the number of 16 byte words remaining in the stack. Any comments?

Graham

RE: uxTaskGetStackHighWaterMark problem?

Posted by Richard on October 19, 2008
Oops, my bad. portSTACK_GROWTH should be set to -1, not -4.

I have corrected this in the SVN head revision and it will get included in the next release.

Thanks for pointing this out.

Regards.


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


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

Latest News

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner