Hello Vicky
I would first suggest you to upgrade to CodeWarrior for HC12 V3.1 or V4.5. Management of banked constants is much simpler with the newer releases.
If you want to stick with V2.0, basically if you want to use banked constants in ANSI library functions you have to perform the following:
· Define your string constants or constants in a user defined string segment or constant segment with attribute PPAGE. As you want to allocate string constants in ROM, you have to use PPAGE to access them.
· Make sure to use far pointers rather than pointer to define any variable pointing to such a string.
Example:
#pragma STRING_SEG PPAGE myStrConst
char *far myStr = "This is a constant String";
#pragma STRING_SEG DEFAULT
#pragma CONST_SEG PPAGE myConst
const char Tab[]= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA};
#pragma STRING_SEG DEFAULT
·
Place your segment in banked memory in your PRM file.· Use option -CpPPAGE=RUNTIME, to tell the compiler you want to access the string using a runtime function. You cannot directly modify the PPAGE register, because the code accessing the string may be located in another banks.
· Add the file datapage.c (located in the LIB\HCI12C\SRC installation directory) to your project. Make sure it comes before ansib.lib in the "Link Order" View.
· Make sure the code in the runtime function is correct. Depending on the MCU you are using, you may have to use a compiler option to activate bank switching for HC12DG128 or HCS12 to select the appropriate page register.
· To activate page switching for HC12DG128, compile with option -DDG128.
· To activate page switching for HCS12, compile with option –DHCS12
· If you intend to use some library functions to manipulate the strings you have to regenerate the library for far string pointer. In this purpose:
· Edit the file libdefs.h located in the installation directory "LIB\HCI\include". In this file modify lines 74 and 78 as follows:
#define LIBDEF_FAR_CONST_STRINGS 1
#define LIBDEF_FAR_STRINGS 1
· Generate the library again. This can be done using the project hc12 lib.mcp located in the installation LIB\HCI directory. Technical note TN105 provide you information how to generate a new library.
If this does not help, submit a service request through the web interface and attach a zip file containing the whole project.
CrasyCat
Hi Vicky,
This reply may be a little late - but perhaps is useful to others?
Datapage.c contains an error - PPAGE on the MC9S12 256 and 512 variants (at least) resides at 0x30 and not 0x35 as Datapage.c defines it.
I had the same issue, and had to manually modify datapage.c to get this to work!
Hopefully this will be fixed in a later version of Codewarrior?