Stack Measurement with FREE RTOS Version 8.0.1

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

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

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

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

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

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

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

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

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

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

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

Stack Measurement with FREE RTOS Version 8.0.1

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

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

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

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

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

Hello , Please find th attachment for the assembly code

Stack Measurement with FREE RTOS Version 8.0.1

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

Stack Measurement with FREE RTOS Version 8.0.1

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

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.

Stack Measurement with FREE RTOS Version 8.0.1

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

ok Thank you