<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic CodeWarrior 8- &amp; 16-bit tools: variables inside paged flash in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/CodeWarrior-8-16-bit-tools-variables-inside-paged-flash/m-p/124851#M114</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #ff0000;"&gt;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.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Posted: Oct 20, 2005 - 03:03 AM&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hi all, I'm working on a MC9S12A128B and codewarrior ver 5.5.&lt;BR /&gt;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).&lt;/P&gt;&lt;P&gt;This is my first attempt:&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG PPAGE TEST&lt;BR /&gt;const unsigned char info1[16]="----- TEST ---\r\n";&lt;BR /&gt;const unsigned int test;&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;and this is part of my linker script:&lt;/P&gt;&lt;P&gt;SECTIONS&lt;BR /&gt;/* List of all sections specified on the "Build options" tab */&lt;BR /&gt;RAM = READ_WRITE 0x00002000 TO 0x00003FFF;&lt;BR /&gt;ROM_C000 = READ_ONLY 0x0000C000 TO 0x0000FF7F;&lt;BR /&gt;ROM_4000 = READ_ONLY 0x00004000 TO 0x00007FFF;&lt;BR /&gt;ROM_PAGE38 = READ_ONLY 0x00388000 TO 0x0038BFFF;&lt;BR /&gt;ROM_PAGE39 = READ_ONLY 0x00398000 TO 0x0039BFFF;&lt;BR /&gt;.......&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;PLACEMENT&lt;BR /&gt;DEFAULT_RAM INTO RAM;&lt;BR /&gt;DEFAULT_ROM INTO ROM_C000;&lt;BR /&gt;_PRESTART, STARTUP,&lt;BR /&gt;ROM_VAR, STRINGS,&lt;BR /&gt;NON_BANKED, COPY INTO ROM_C000, ROM_4000;&lt;BR /&gt;TEST INTO ROM_PAGE38;&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;and my build options:&lt;BR /&gt;-BfaGapLimitBits0 -D_HCS12 -D__NO_FLOAT__ -Mb -WmsgSe1140 -WmsgSe1801 -CpPpage=RUNTIME -CpPpage=0x30&lt;/P&gt;&lt;P&gt;unfortunately these variables are allocated inside the internal RAM.&lt;/P&gt;&lt;P&gt;I can store my data section as i desire only if I define it in this way:&lt;/P&gt;&lt;P&gt;#pragma CONST_SEG PPAGE TEST&lt;BR /&gt;const unsigned char info1[16]="----- TEST ---\r\n";&lt;BR /&gt;#pragma CONST_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PLACEMENT&lt;BR /&gt;DEFAULT_RAM INTO RAM;&lt;BR /&gt;DEFAULT_ROM INTO ROM_C000;&lt;BR /&gt;_PRESTART, STARTUP,&lt;BR /&gt;ROM_VAR, STRINGS,&lt;BR /&gt;NON_BANKED, COPY INTO ROM_C000, ROM_4000;&lt;BR /&gt;_PPAGE INTO ROM_PAGE38;&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;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?)&lt;/P&gt;&lt;P&gt;I hope somebody can explain me this strange behavior, I'm very confused.&lt;BR /&gt;thanks everibody&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Posted: Oct 21, 2005 - 11:24 AM&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;There are two issues here:&lt;BR /&gt;1- when you define a user define constant you have to use&lt;BR /&gt;#pragma CONST_SEG instead of #pragma DATA_SEG&lt;/P&gt;&lt;P&gt;2- PPAGE is a macro defined in the file mc9s12a128.h so you have to use&lt;BR /&gt;__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.&lt;/P&gt;&lt;P&gt;The constant definition should look like:&lt;BR /&gt;#pragma CONST_SEG __PPAGE_SEG TEST&lt;BR /&gt;const unsigned char info1[16]="----- TEST ---\r\n";&lt;BR /&gt;const unsigned int test;&lt;BR /&gt;#pragma CONST_SEG DEFAULT&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Ron&lt;/P&gt;&lt;P&gt;_________________&lt;BR /&gt;Ron Liechty&lt;BR /&gt;Ombudsman for Metrowerks&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 28 Jan 2006 01:49:34 GMT</pubDate>
    <dc:creator>marc_paquette</dc:creator>
    <dc:date>2006-01-28T01:49:34Z</dc:date>
    <item>
      <title>CodeWarrior 8- &amp; 16-bit tools: variables inside paged flash</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/CodeWarrior-8-16-bit-tools-variables-inside-paged-flash/m-p/124851#M114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #ff0000;"&gt;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.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Posted: Oct 20, 2005 - 03:03 AM&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hi all, I'm working on a MC9S12A128B and codewarrior ver 5.5.&lt;BR /&gt;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).&lt;/P&gt;&lt;P&gt;This is my first attempt:&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG PPAGE TEST&lt;BR /&gt;const unsigned char info1[16]="----- TEST ---\r\n";&lt;BR /&gt;const unsigned int test;&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;and this is part of my linker script:&lt;/P&gt;&lt;P&gt;SECTIONS&lt;BR /&gt;/* List of all sections specified on the "Build options" tab */&lt;BR /&gt;RAM = READ_WRITE 0x00002000 TO 0x00003FFF;&lt;BR /&gt;ROM_C000 = READ_ONLY 0x0000C000 TO 0x0000FF7F;&lt;BR /&gt;ROM_4000 = READ_ONLY 0x00004000 TO 0x00007FFF;&lt;BR /&gt;ROM_PAGE38 = READ_ONLY 0x00388000 TO 0x0038BFFF;&lt;BR /&gt;ROM_PAGE39 = READ_ONLY 0x00398000 TO 0x0039BFFF;&lt;BR /&gt;.......&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;PLACEMENT&lt;BR /&gt;DEFAULT_RAM INTO RAM;&lt;BR /&gt;DEFAULT_ROM INTO ROM_C000;&lt;BR /&gt;_PRESTART, STARTUP,&lt;BR /&gt;ROM_VAR, STRINGS,&lt;BR /&gt;NON_BANKED, COPY INTO ROM_C000, ROM_4000;&lt;BR /&gt;TEST INTO ROM_PAGE38;&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;and my build options:&lt;BR /&gt;-BfaGapLimitBits0 -D_HCS12 -D__NO_FLOAT__ -Mb -WmsgSe1140 -WmsgSe1801 -CpPpage=RUNTIME -CpPpage=0x30&lt;/P&gt;&lt;P&gt;unfortunately these variables are allocated inside the internal RAM.&lt;/P&gt;&lt;P&gt;I can store my data section as i desire only if I define it in this way:&lt;/P&gt;&lt;P&gt;#pragma CONST_SEG PPAGE TEST&lt;BR /&gt;const unsigned char info1[16]="----- TEST ---\r\n";&lt;BR /&gt;#pragma CONST_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PLACEMENT&lt;BR /&gt;DEFAULT_RAM INTO RAM;&lt;BR /&gt;DEFAULT_ROM INTO ROM_C000;&lt;BR /&gt;_PRESTART, STARTUP,&lt;BR /&gt;ROM_VAR, STRINGS,&lt;BR /&gt;NON_BANKED, COPY INTO ROM_C000, ROM_4000;&lt;BR /&gt;_PPAGE INTO ROM_PAGE38;&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;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?)&lt;/P&gt;&lt;P&gt;I hope somebody can explain me this strange behavior, I'm very confused.&lt;BR /&gt;thanks everibody&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Posted: Oct 21, 2005 - 11:24 AM&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;There are two issues here:&lt;BR /&gt;1- when you define a user define constant you have to use&lt;BR /&gt;#pragma CONST_SEG instead of #pragma DATA_SEG&lt;/P&gt;&lt;P&gt;2- PPAGE is a macro defined in the file mc9s12a128.h so you have to use&lt;BR /&gt;__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.&lt;/P&gt;&lt;P&gt;The constant definition should look like:&lt;BR /&gt;#pragma CONST_SEG __PPAGE_SEG TEST&lt;BR /&gt;const unsigned char info1[16]="----- TEST ---\r\n";&lt;BR /&gt;const unsigned int test;&lt;BR /&gt;#pragma CONST_SEG DEFAULT&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Ron&lt;/P&gt;&lt;P&gt;_________________&lt;BR /&gt;Ron Liechty&lt;BR /&gt;Ombudsman for Metrowerks&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jan 2006 01:49:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/CodeWarrior-8-16-bit-tools-variables-inside-paged-flash/m-p/124851#M114</guid>
      <dc:creator>marc_paquette</dc:creator>
      <dc:date>2006-01-28T01:49:34Z</dc:date>
    </item>
  </channel>
</rss>

