PLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. */ _PRESTART, /* Used in HIWARE format: jump to _Startup at the code start */ STARTUP, /* startup data structures */ ROM_VAR, /* constant variables */ STRINGS, /* string literals */ VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */ //.ostext, /* eventually OSEK code */ NON_BANKED, /* runtime routines which must not be banked */ //COPY /* copy down information: moved to banked flash */ /* in case you want to use ROM_4000 here as well, make sure that all files (incl. library files) are compiled with the option: -OnB=b */ INTO ROM_C000, ROM_4000; DEFAULT_ROM, COPY /* copy down information: how to initialize variables */ INTO PAGE_FE, PAGE_FC, PAGE_FB, PAGE_FA, PAGE_F9, PAGE_F8, /* use the following ranges only when same module is NOT used for XGATE code */ /* PAGE_E0, PAGE_E1, intentionally not listed: assigned to XGATE */ PAGE_E7, PAGE_E6, PAGE_E5, PAGE_E4, PAGE_E3, PAGE_E2, PAGE_E0_0;
Solved! Go to Solution.
All,
Synopsis of Problem:
------------------------
In my project, the non-banked area has run-out of memory and hence I cannot add any more string literals or string constants. In order to overcome the problem I would want to create string literals/constants in STRING_SEG and assign it in the paged memory and access it at runtime using strcpy function. It seems that the strcpy function doesn't seem to work and it is still accessing PPAGE = 0; Please see the steps I have performed and let me know if any modifications needs to be done.
I am using CodeWarrior V2.0 and the code is being developed in C++.
I am referring to the link below and FAQ-27439 which provided some excellent insight in creating paged string literals.
http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=757&query.id=3812#....
Steps Done:
--------------
1. In the .h file in my project, I declared const char *__far mystring;
*** Question**** mystring is not a global variable, can that be a problem ?
2. In the .c file, I have the following pragma declaration,
#pragma STRING_SEG __PPAGE_SEG CONST_STRING
const char *__far mystring = "Good Morning America";
#pragma STRING_SEG DEFAULT
*** Question**** Any restriction on where to place the pragma in the code ?
3. Compiler Settings was modified to include -CpPPAGE=RUNTIME,
done by Edit >> P&E Settings >> Compiler for HCS12 >> Options >> Code Generation >> PPAGE register is used for
paging (checked this box)
4. Since I couldn't find -DHCS12 as a compiler option among the options in checkboxes, I manually added -DHCS12 to the
Command Line Argument for the Compiler.
The Command Line Argument now reads as shown below.
-C++c -Cc -CpPPAGE=RUNTIME -DHCS12 -Lasm=%n.lst -Mb -Ona -OnB -Onbf -Onbt -Onca -Oncn -OnCstVar -One -OnP -OnPMNC -Ont -WmsgSd1048 -WmsgSd1420 -WmsgSd2705 -WmsgSd4000 -WmsgSd4001 -WmsgSd12056
5. Edited lines 74 & 78 LIBDEFS.h file in [install]/lib/HC12c/INCLUDE.
#define LIBDEF_FAR_CONST_STRINGS 1
#define LIBDEF_FAR_STRINGS 1
***** Please find the LIBDEFS.H attached along with this post. Could you please verify this file ?
6. Rebuilt the project in [install]/lib/HC12c/hc12 lib.mcp. Rebuilt using the "Make" option in Project tab.
7. Added DATAPAGE.c from [install]/lib/HC12c/SRC. Moved it higher up than ANSIB.LIB in the Link Order Hierarchy.
***** NOTE**** When I add DATAPAGE.C it gets added among the source files that I have created in my project.. Is this correct ?
8. Did a clean build for my project, the project compiles and loads into the micro. I did check the memory location where the
constant string I declared, mystring is located and it is placed in the intended memory location, i.e. 0x3D8000.
9. I am referencing mystring in my project using the following code,
long TestCharPtr; // debug variable
TestCharPtr = (long) (mystring + 2); // assigning address of mystring; TempCharPtr shows value of 0x0002 (lower 4 byte address instead of 0x3d8002)
strcpy((char *)tempstring, (char *__far)mystring); // accessing the STRING.C function
Thus the value returned is wrong since I guess it is accessing the wrong address.
Could you please let me know if the steps performed are correct and any thoughts into the problem?
Sincerely,