CodeWarrior local variable storage location

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

CodeWarrior local variable storage location

跳至解决方案
1,891 次查看
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 项奖励
回复
1 解答
1,654 次查看
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!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

5 回复数
1,654 次查看
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 项奖励
回复
1,653 次查看
xaing_wang
Contributor I

Hello Jennie,

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

      tks。

0 项奖励
回复
1,655 次查看
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,654 次查看
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 项奖励
回复
1,654 次查看
xaing_wang
Contributor I

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

0 项奖励
回复