Stack Measurement with FREE RTOS Version 8.0.1

jaswanthkamadan wrote on Tuesday, 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

rtel wrote on Tuesday, 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).

jaswanthkamadan wrote on Tuesday, 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

rtel wrote on Tuesday, 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.

jaswanthkamadan wrote on Tuesday, 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?

rtel wrote on Tuesday, 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.

jaswanthkamadan wrote on Tuesday, June 20, 2017:

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

if(TRUE == EL_Wdog_InitCompleteFlag)
{

}
}

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

rtel wrote on Tuesday, 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.

jaswanthkamadan wrote on Tuesday, 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

jaswanthkamadan wrote on Tuesday, 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

rtel wrote on Tuesday, June 20, 2017:

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

rtel wrote on Tuesday, June 20, 2017:

Is this correct statement?

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

jaswanthkamadan wrote on Tuesday, 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

jaswanthkamadan wrote on Tuesday, June 20, 2017:

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

jaswanthkamadan wrote on Wednesday, 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

rtel wrote on Wednesday, 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.

jaswanthkamadan wrote on Wednesday, June 21, 2017:

Hello ,

Please find th attachment for the assembly code

rtel wrote on Wednesday, June 21, 2017:

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

jaswanthkamadan wrote on Wednesday, June 21, 2017:

rtel wrote on Wednesday, 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.