S12X/XGATE runtime library needs too much RAM

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

S12X/XGATE runtime library needs too much RAM

5,111 次查看
pittbull
Contributor III
Hello,

I'm using CodeWarrior for HCS12X version 4.1. I wonder why the libraries need so much RAM? When I look at the project window, there are ansixbi.lib and ansi_xgi.lib which occupy 2019 and 2018 bytes of RAM. How can I reduce this?

Thanks in advance,
pittbull
标签 (1)
标记 (1)
0 项奖励
回复
4 回复数

1,445 次查看
BlackNight
NXP Employee
NXP Employee
Hi,
yes, most are only using stack variables, and no global memory/RAM. The exception is the heap managment (malloc, etc) where there is a global area of RAM you can allocate. Have a look at the libdefs.h header file how to configure the heap size.
But if you are not using any malloc()/etc, it is dead-stripped/removed by the linker.

Erich
0 项奖励
回复

1,445 次查看
pittbull
Contributor III
Hi Erich,
Thanks again.
I don't know which algorithm the codewarrior-supplied heap routines use, but most embedded heaps that are based on linked lists need one ore two pointers in global RAM (beside the heap memory itself). This should be max. 4 bytes under a 16 bit platform. So I think there must be some other library functions which waste memory....
BTW: I hardly never use heap routines in embedded development :smileywink:
0 项奖励
回复

1,445 次查看
BlackNight
NXP Employee
NXP Employee
Hello,
you should not be worried about the sizes reported a the project window: the project window will list you the memory/flash/RAM allocation for the whole package/library/files. I mean it is the 'worst' case and only if you would link and use _everything_ in it.
The linker is a smart linker and will only link and use what is used by your application. So if you link the library with your application, and you are not using any library stuff, it will not consume RAM/Flash in your application at all. Have a look at the produced .map file by the linker and you will see that the amount of RAM/Flash will go down to the level what you really use.

Thanks,
Erich
0 项奖励
回复

1,445 次查看
pittbull
Contributor III
Hello Erich,
Thanks for the reply. I know that some library functions need much Flash memory (e.g. sprintf). But which functions need static RAM (as shown in the project window)? I think most of them use local (stack) variables. Am I wrong?
Can you tell me please, which library functions one must avoid to save RAM?
0 项奖励
回复