Hi,
I'm new to this forum, but I have been reading quite a few threads in the hope to find some clues as to how I should make const declared variables end up in ROM instead of RAM. I haven't found the answer yet, so I was hoping to get some help here...
I'm using CW5.5 and the target is the GC16 (1kB RAM) microcontroller (I'm new to this too...).
What I have is something like this:
in the .prm file:
SEGMENTS
RAM = READ_WRITE 0x0C00 TO 0x0FFF; //9S12GC16
/* unbanked FLASH ROM */
ROM_C000 = READ_ONLY 0xC000 TO 0xFEFF; //9S12GC16
END
PLACEMENT
_PRESTART, STARTUP,
ROM_VAR, STRINGS,
VIRTUAL_TABLE_SEGMENT,
DEFAULT_ROM, NON_BANKED ,
OTHER_ROM , COPY INTO ROM_C000; //9S12GC16
DEFAULT_RAM INTO RAM;
END
STACKSIZE 0x100
in my c-file.
static const unsigned char a[ ] = {1, 5};
static const unsigned char b[ ] = {2, 6};
static const unsigned char c[ ] = {3, 7};
static const unsigned char d[ ] = {4, 8};
static const unsigned char* p_misc_0[ ] = {a, b};
static const unsigned char* p_misc_1[ ] = {c, d};
static const unsigned char** p_misc[ ] = {p_misc_0, p_misc_1};
In the .map file I then find the following:
- a,b,c, and d all end up in .rodata (ROM as expected)
- p_misc_0, p_misc_1, and p_misc all end up in .data (RAM!)
- All "non const" declared variables end up in .bss (RAM)
I believe that this is in the ELF object file format, and therefore #pragma INTO_ROM cannot be used. (Using this directive will fool the .mcp window to not count the variables as data, but the linker is not buying it!) I've been browsing the CW help for hours, but it just gets me confused, what with all the pragma directives and compiler options available...
I'd like to think that there's an easy way to put the const vars in ROM. Any help is much appreciated.
Thanks,
Anders.