Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 20, 2017

Hello All,

I am using the microcontroller MC9S12XET256MAG, with Free RTOS Version 8.0.1.,

I am facing one issue like, if I increase the number local variables in the task, there is no change in the stack measurement.So my question is

1) the above situation is correct. If yes, They can you please explain me what are the things stored in the stack of the perticular task? 2) If no, Can you please explain me how to measure the stack of the task without "uxTaskGetStackHighWaterMark" Function Call?

Thanks in Advance

Regards Jaswanth


Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 20, 2017

FreeRTOS does not change how the compiler stores items, be that on the stack or in registers. It is a problem with the measurement on that particular device. Another user mentioned the same thing recently but I don't think it was concluded. However it is known that the stack measurement doesn't work on devices that have segmented memory spaces (base/offset registers, rather than a linear address space).


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 20, 2017

Thanks For your Information.

But, number of "0xA5"(the value present the stack while creating the task) present in the stack of the perticular task is equal to the calculated value given by the "uxTaskGetStackHighWaterMark".

Is there any other method method to calculate the stack size for segmented memory spaces?

is this issue , alsoavailable in the never version of the RTOS?

Thanks & Regards Jaswanth


Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 20, 2017

But, number of "0xA5"(the value present the stack while creating the task) present in the stack of the perticular task is equal to the calculated value given by the "uxTaskGetStackHighWaterMark".

Yes, that is how it is supposed to be. I'm confused, is this working for you then? Your original post seemed to indicate it wasn't working. If it's not working then you can step into the uxTaskGetStackHighWaterMark() function in the debugger to determine where it is erring.


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 20, 2017

But, If I Increase local variables in the task, then stack should grow right? But it is not growing.same number of 0xA5's are availble as same as before adding the local variables.

You told in segmented models, the stack stack size is not working. usually this device is a segmented model only. But heap is stored in the Linear address from 0x2000 to 0x3FFF. here also it will not work?


Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 20, 2017

Ignore the segmented thing for now, as it seems to be working.

Are you sure your compiler is allocating the variables on the stack? Perhaps it has put them elsewhere - although as I recall that device has very few registers so the stack would seem to be the most likely place. Can you show the code that is declaring the local variables.


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 20, 2017

void ELWatchDogTask(void) { uint16 temp[30] = {0};

if(TRUE == ELWdogInitCompleteFlag) {

} }

temp[30] is the local variable here. It is added newly. And i have 15 tasks all the tasks having same stack measurement. As per my understanding for temp[30] 30*2 = 60 bytes of memory should allocate. Is this correct?

i dont know why this is behaving like ? i configured the stack size of 150.

Thanks and Regards Jaswanth


Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 20, 2017

I think you would have to look at the code generated by the compiler. Some compilers [for very small devices] will use overlays where multiple variables are placed in the same memory if the compiler can determine that there is no way for them to be needed at the same time.


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 20, 2017

Thanks For Your Information,

But, why All the 15 tasks using the same number of bytes of stack?

Thanks and Regards Jaswanth


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 20, 2017

So, As per your above comments i am concluding that , the local variables or Global variables will not goes to stack of the task(beacuse this is the heap memory). Hence stack of the task is not growing.

Is this correct statement?

Thanks and Regards Jaswanth


Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 20, 2017

Have you stepped through the code in the debugger to see?


Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 20, 2017

Is this correct statement?

Only you have the assembly code in front of you to know this.


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 20, 2017

I Have the assembly code. But i dont know much about assembly?

How can we tell this statement is correct using assembly code of the perticular task.

Thanks & Regards Jaswanth


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 20, 2017

Yes. I stepped through the code. It is same. No of the used bytes by the tasks are same.


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 21, 2017

Hello,

Can you please explain me with small example of assembly cde, How we tell above statement is correct?

Thanks & Regrds Jaswanth


Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 21, 2017

I can't see that you posted any asm code. If you did, unless it was obvious from the code, I would probably need to look up the instructions anyway. Try posting the asm code for the function entry and we can see.


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 21, 2017

Hello ,

Please find th attachment for the assembly code


Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 21, 2017

Which function in that disassembly am I looking at? Which line is the first line of the function?


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 21, 2017

Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 21, 2017

Didn't notice before. The variable is declared static, which means it will not be on the stack. Static variables will never be on the stack - this is more of a C question than a FreeRTOS question.


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 21, 2017

Sorry i forgot to remove the static keyword, While testing i kept it.

see the code below ...

void ELWatchDogTask(void) { uint16 temp[30] = {0};

if(TRUE == ELWdogInitFlag) { if(FALSE == DTCLogFlag) { (void)MLWDogReloadWDog();

      EL_WatchDog_Funce();
}

} }

assembly first line pointing to uint16 temp[30] = {0}; line.

assembly snippet attached below.

Attachments

assembly1.PNG (22246 bytes)

Stack Measurement with FREE RTOS Version 8.0.1

Posted by rtel on June 21, 2017

I have just downloaded the instruction set manual - which you could have done yourself - and see that the sequence of std instructions are storing bytes from the D register to two consecutive addresses and it appears to be using stack pointer offset addressing. It is not clear that the stack pointer itself is updated though.

This is well outside of FreeRTOS support - so I will let you pick it up from here.


Stack Measurement with FREE RTOS Version 8.0.1

Posted by jaswanthkamadan on June 21, 2017

ok Thank you


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists