HCS12X将heap放入paged RAM

转自:http://www.freescale.com/webapp/sps/utils/SingleFaq.jsp?FAQ-27635.xml

 

With CodeWarrior for HCS12(X), is it possible to place the heap in paged RAM?
Last Modified date
04JUN2007
Topic
*       CodeWarrior Development Tools
*       Software Development

Question.  With CodeWarrior for HCS12(X), is it possible to place the heap in paged RAM?

Answer.  This is possible for HCS12X and HCS12XE only.

If you are building the program with the banked memory model and if you want to allocate your heap in paged memory, you need to do the following:

1) Open the file {Install}\lib\hc12c\include\libdefs.h with the editor.

2) Go to line 180 and change:

#define LIBDEF_FAR_HEAP_DATA 0

to:

#define LIBDEF_FAR_HEAP_DATA 1

3) On line 193, change the value of LIBDEF_HEAPSIZE to the desired size.

4) If you intend to use dynamically allocated data with other ANSI C functions, you also need to edit the macros LIBDEF_FAR_CONST_STRINGS, LIBDEF_FAR_STRINGS, LIBDEF_FAR_CONST_VOID_PTR, and LIBDEF_FAR_VOID_PTR so that their values are 1 instead of 0.

5) There is an issue in the delivered alloc.c source file.

Edit the file alloc.c and change it as follows. Change line 84 from:

free_ptr = (header *) &_heap_[0];

to

free_ptr = (header *LIBDEF_HEAP_DPTRQ) &_heap_[0];

6) Rebuild the libraries.

7) In your .prm file, define a global memory area to store your heap. If you need 28000 bytes of heap, then the paged RAM area should be defined as:

GLOBAL_RAM = NO_INIT 0xF8000'G TO 0xFDFFF'G;

Define the big paged memory area as NO_INIT so it will not be initialized at Startup.

8) In your .prm file, place HEAP_SEGMENT in GLOBAL_RAM.

An error in the malloc() function is present in CodeWarrior for HCS12(X) V4.5 & V4.6.
It will be fixed in a later release of the libraries.

你可能感兴趣的:(职场,heap,RAM,休闲,hcs12x)