<?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 Re: code and constants in same segment in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/code-and-constants-in-same-segment/m-p/201033#M7553</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;However, at the #pragma to place the functions, I get the error "Segment name already used"&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Probably&amp;nbsp;linker needs code and data to go to different placement identities. Else, I guess, it wouldn't be able to count how much data you code your have, maybe other map file issues etc.&lt;/P&gt;&lt;P&gt;You don't need separate segment records&amp;nbsp;(segments) for code and data in prm file, but you need separate placement records so that your data and functions are combined into the same ppage. I thing there's no other known way to force dedicated data and functions to the same ppage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PLACEMENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mydata INTO PAGE_3A;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mycode INTO PAGE_3A;&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CONST_SEG mydata&lt;BR /&gt;static const int tab[]=&lt;BR /&gt;{&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;};&lt;BR /&gt;#pragma CONST_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG mycode&lt;BR /&gt;int foo(int i)&lt;/P&gt;&lt;P&gt;{}&lt;BR /&gt;#pragma CODE_SEG DEFAULT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Apr 2011 12:12:09 GMT</pubDate>
    <dc:creator>kef</dc:creator>
    <dc:date>2011-04-27T12:12:09Z</dc:date>
    <item>
      <title>code and constants in same segment</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/code-and-constants-in-same-segment/m-p/201032#M7552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using CW 5.0 for S12X.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a large, constant table that is used only by a few functions, so I want to have both the table and those functions in their own segment:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CONST_SEG DISPATCH_SEG&lt;/P&gt;&lt;P&gt;const DispatchRec DIspatchTable[] = {&lt;/P&gt;&lt;P&gt;// entries in dispatch table&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;#pragma CONST_SEG DEFAULT_SEG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG DISPATCH_SEG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, at the #pragma to place the functions, I get the error "Segment name already used"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using DISPATCH_TABLE and DISPATCH_CODE, then placing them into the same section in the linker directives, but unless I define a section specifically for these 2 segments, the linker places them in different 16k banks. (The 2 segments total less than 16k).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to get this to work without having to define a seperate section to hold these 2 segments? The reason I ask is that there are other table/function combinations I want to treat the same way, so if I have to define a section for each pair, I am then taking full control of the memory allocation for most of my application, which is a lot of extra work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2011 23:25:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/code-and-constants-in-same-segment/m-p/201032#M7552</guid>
      <dc:creator>rlw</dc:creator>
      <dc:date>2011-04-26T23:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: code and constants in same segment</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/code-and-constants-in-same-segment/m-p/201033#M7553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;However, at the #pragma to place the functions, I get the error "Segment name already used"&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Probably&amp;nbsp;linker needs code and data to go to different placement identities. Else, I guess, it wouldn't be able to count how much data you code your have, maybe other map file issues etc.&lt;/P&gt;&lt;P&gt;You don't need separate segment records&amp;nbsp;(segments) for code and data in prm file, but you need separate placement records so that your data and functions are combined into the same ppage. I thing there's no other known way to force dedicated data and functions to the same ppage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PLACEMENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mydata INTO PAGE_3A;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mycode INTO PAGE_3A;&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CONST_SEG mydata&lt;BR /&gt;static const int tab[]=&lt;BR /&gt;{&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;};&lt;BR /&gt;#pragma CONST_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG mycode&lt;BR /&gt;int foo(int i)&lt;/P&gt;&lt;P&gt;{}&lt;BR /&gt;#pragma CODE_SEG DEFAULT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2011 12:12:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/code-and-constants-in-same-segment/m-p/201033#M7553</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-04-27T12:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: code and constants in same segment</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/code-and-constants-in-same-segment/m-p/201034#M7554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When programming in ANSI C you cannot mix code and constants in the same section.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As kef indicated in his post, you can place code and constant section in the same memory area in the .prm file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2011 16:48:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/code-and-constants-in-same-segment/m-p/201034#M7554</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2011-04-27T16:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: code and constants in same segment</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/code-and-constants-in-same-segment/m-p/201035#M7555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically what I am doing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(oops, I reversed the terms segment and section)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By shuffling the order of sections in the PLACEMENT section of the PRM, I was able to get both sections in the same 16k page, however, it seems the best way to avoid constant reshuffling is to place each table/function section pair is to allocate a segment for each pair, then place each pair into its designated segment:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SEGMENTS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISPATCH = READ_ONLY&amp;nbsp;0x7C0000'G TO 0x7C3FFF'G;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TASKS = READ_ONLY&amp;nbsp;0x7C4000'G TO 0x7C7FFF'G;&lt;/P&gt;&lt;P&gt;// other segments&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PLACEMENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISPATCH_TABLE, DISPATCH_CODE INTO DISPATCH;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TASKS_TABLE, TASKS_CODE INTO TASKS;&lt;/P&gt;&lt;P&gt;// other placements&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for restrictions on grouping code and data, I thought that restriction only applied to Read/Write data, not constant data. Besides, 1 and 2 byte constants are often "in lined" as immediate values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2011 21:07:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/code-and-constants-in-same-segment/m-p/201035#M7555</guid>
      <dc:creator>rlw</dc:creator>
      <dc:date>2011-04-27T21:07:47Z</dc:date>
    </item>
  </channel>
</rss>

