MC56F8006 - Setting Stack and Heap Size on Processor Expert

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

MC56F8006 - Setting Stack and Heap Size on Processor Expert

1,119 次查看
rmarques
Contributor I

Hello, I am using Codewarrior IDE version 5.9.0 on an old Windows XP computer and a MC56F8006 microcontroller.

I have been familiarizing myself with this chip, IDE, and Processor Expert tool and I already understand that the chip has an integrated RAM of 2KBytes, with 1K addressable 16-bit words.

On the build options of the CPU component inspector, I have 3 memory areas, 2 for interrupt and program memory and the third one for data memory. This last one has the start address on 1 and size 3FF. Inspecting the memory map yields me the expected results, with total RAM having 1024 addresses, of which I am using 1023 (since the start is on 0x0001 instead of 0x0000 - just got into this project, will probably change it later to start on 0x0000).

Currently, I would like to add an array of 25 ints to my code but I am limited to 15 or so before I get an overflow error while building the project. I noticed the stack size is defined as 0x00A0 and the heap size as 0x0060. This does not make sense, as I have 2 globally accessible arrays of 256 ints each already that I cannot put in program memory since their values change on runtime and I cannot possibly fit 512 ints on 0x0060 (0d96) addresses - the heap size.

I feel like I am missing something. Also, I cannot increase the stack or the heap by as little as 16 addresses since it also results in segment overflows. I would suspect that I could distribute the available 1023 addresses of the RAM by the stack and the heap - 800 addresses for the heap and 223 for the stack for example, but this does not seem to be the case. Little help, please?

0 项奖励
回复
4 回复数

1,062 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

From the following screenshot, you can see that the MC56F8006 has only 16KB flash, 2KB RAM, so you have to care about the RAM utilization.

Because you do not write data in application code, so you do not need allocate space for the PRAM.

Because you do not use malloc() to dynamically allocate memory, you can set the heap size to zero. The stack is required.

Hope it can help you

BR'

XiangJun Rong

xiangjun_rong_0-1654852713232.png

xiangjun_rong_1-1654856207256.png

 

0 项奖励
回复

1,060 次查看
rmarques
Contributor I

From my understanding, as long as the size of the heap and stack together do not exceed the total 1024Bytes of the RAM, it should be ok. My question is why it is not.

0 项奖励
回复

1,036 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

For example, you declare a global array:

uint16_t uArray[1000];

void main()

{

uint16_t i;

for(i=0; i<1000; i++)

{

uArray[i]=i;

}

...........

}

The vaiable i is located in stack, but the uArray is located in neither heap not stack, it occupies space.

Hope it can help you

BR

XiangJun Rong

0 项奖励
回复

1,034 次查看
rmarques
Contributor I

Well, now I feel stupid, thank you for teaching me. I looked for this online and I understand now why I could not increase the stack or heap size much more.

0 项奖励
回复