CodeWarrior 8- & 16-bit tools: variables inside paged flash

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CodeWarrior 8- & 16-bit tools: variables inside paged flash

2,254 Views
marc_paquette
Contributor V
To help you find solutions to problems that have already been solved, we have posted this message. It contains an entire topic ported from a separate forum. The original message and all replies are in this single message.
 

Posted: Oct 20, 2005 - 03:03 AM   

Hi all, I'm working on a MC9S12A128B and codewarrior ver 5.5.
I've got about 16k of constant data and I'd like to put them in the paged flash (block 0 pages from 38h to 3Bh).

This is my first attempt:

#pragma DATA_SEG PPAGE TEST
const unsigned char info1[16]="----- TEST ---\r\n";
const unsigned int test;
#pragma DATA_SEG DEFAULT


and this is part of my linker script:

SECTIONS
/* List of all sections specified on the "Build options" tab */
RAM = READ_WRITE 0x00002000 TO 0x00003FFF;
ROM_C000 = READ_ONLY 0x0000C000 TO 0x0000FF7F;
ROM_4000 = READ_ONLY 0x00004000 TO 0x00007FFF;
ROM_PAGE38 = READ_ONLY 0x00388000 TO 0x0038BFFF;
ROM_PAGE39 = READ_ONLY 0x00398000 TO 0x0039BFFF;
.......
END

PLACEMENT
DEFAULT_RAM INTO RAM;
DEFAULT_ROM INTO ROM_C000;
_PRESTART, STARTUP,
ROM_VAR, STRINGS,
NON_BANKED, COPY INTO ROM_C000, ROM_4000;
TEST INTO ROM_PAGE38;
END

and my build options:
-BfaGapLimitBits0 -D_HCS12 -D__NO_FLOAT__ -Mb -WmsgSe1140 -WmsgSe1801 -CpPpage=RUNTIME -CpPpage=0x30

unfortunately these variables are allocated inside the internal RAM.

I can store my data section as i desire only if I define it in this way:

#pragma CONST_SEG PPAGE TEST
const unsigned char info1[16]="----- TEST ---\r\n";
#pragma CONST_SEG DEFAULT


PLACEMENT
DEFAULT_RAM INTO RAM;
DEFAULT_ROM INTO ROM_C000;
_PRESTART, STARTUP,
ROM_VAR, STRINGS,
NON_BANKED, COPY INTO ROM_C000, ROM_4000;
_PPAGE INTO ROM_PAGE38;
END

I can place integers inside my section only if they're part of a struct. otherwise if I look inside the .map file created by the linker, I can't find any section named _PPAGE (where are my integers stored?)

I hope somebody can explain me this strange behavior, I'm very confused.
thanks everibody
 
 

Posted: Oct 21, 2005 - 11:24 AM   

There are two issues here:
1- when you define a user define constant you have to use
#pragma CONST_SEG instead of #pragma DATA_SEG

2- PPAGE is a macro defined in the file mc9s12a128.h so you have to use
__PPAGE_SEG as attribute in your constant definition. Currently the preprocessor expands PPAGE in something pretty strange, which is not doing what the customer wants.

The constant definition should look like:
#pragma CONST_SEG __PPAGE_SEG TEST
const unsigned char info1[16]="----- TEST ---\r\n";
const unsigned int test;
#pragma CONST_SEG DEFAULT

Hope this helps,

Ron

_________________
Ron Liechty
Ombudsman for Metrowerks
 

 
 
Labels (1)
Tags (1)
0 Kudos
0 Replies