CodeWarrior local variable storage location

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CodeWarrior local variable storage location

Jump to solution
2,078 Views
xaing_wang
Contributor I

In debug,I find that address of  local variable is not Stack。below the figure :

局部变量分配到ram区,并不是堆栈区.jpg

And the local variable define  in function  as follows:

uint8_t i = 0u , j = 0u;

The Ram and Stack define in mc9s12zvl32.prm as follows :

 RAM           = READ_WRITE  0x001100 TO 0x0013FF;

SHADOW_RAM    = READ_WRITE  0x001000 TO 0x001100;

So,I want to know how to define local variables are stored in the stack?

0 Kudos
Reply
1 Solution
1,841 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Wang.

I just checked your project, but I haven't find stack problem.

As I said before, Stack address is inside the RAM section.

see your map file, we can know stack is allocated from address 0x1100 to 0x11ff.

while variable "i" and "j" are in this range.

pastedImage_1.png

Does this answer your questions?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

5 Replies
1,841 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hello.

Stack belongs to RAM section. Normally if you define a local variable, it should be automatically allocated in stack.

Can you please send me your demo project thus I can check your memory allocation from my side?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
1,840 Views
xaing_wang
Contributor I

Hello Jennie,

      I don't have your email,so,I uploaded to  Baidu SkyDrive demo project。

      tks。

0 Kudos
Reply
1,842 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Wang.

I just checked your project, but I haven't find stack problem.

As I said before, Stack address is inside the RAM section.

see your map file, we can know stack is allocated from address 0x1100 to 0x11ff.

while variable "i" and "j" are in this range.

pastedImage_1.png

Does this answer your questions?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,841 Views
xaing_wang
Contributor I

Thank you Jennie。You are right.

I am mistaken "SHADOW_RAM  = READ_WRITE  0x001000 TO 0x001100;"   for  Stack.

By the way,How do I define stack location?such as in the end of RAM.

0 Kudos
Reply
1,841 Views
xaing_wang
Contributor I

http://pan.baidu.com/s/1c2Mjrvq   password:i5a7

0 Kudos
Reply