<?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>Classic/Legacy CodeWarriorのトピックRe: HCX12 c lib &amp;amp; paged ram</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/HCX12-c-lib-amp-paged-ram/m-p/1890435#M7936</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;as I wrote before.&lt;/P&gt;
&lt;P&gt;The easiest way is to open new project and copy all c and h files to it.&lt;/P&gt;
&lt;P&gt;You will avoid all unexpected errors.&lt;/P&gt;
&lt;P&gt;We have done it always in this way because there can anytime appear any new issue because libraries incompatibility.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Ladislav&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jun 2024 13:25:10 GMT</pubDate>
    <dc:creator>lama</dc:creator>
    <dc:date>2024-06-19T13:25:10Z</dc:date>
    <item>
      <title>HCX12 c lib &amp; paged ram</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/HCX12-c-lib-amp-paged-ram/m-p/1878957#M7931</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;We are using cw 5.1 &amp;amp; mc9s12xdt512 controller&lt;BR /&gt;We have created a bank model project, and we recompiled the c lib so it can work with paged RAM.&lt;/P&gt;&lt;P&gt;We have done the following steps:&lt;BR /&gt;&amp;nbsp;-We have copied the lib project ({Install}\lib\hc12c\hc12_lib.mcp).&lt;BR /&gt;&amp;nbsp;-Open the file libdefs.h in an edit window.&lt;BR /&gt;&amp;nbsp;- We have set the macros LIBDEF_FAR_CONST_STRINGS, LIBDEF_FAR_STRINGS, LIBDEF_FAR_CONST_VOID_PTR, LIBDEF_FAR_VOID_PTR and LIBDEF_FAR_CONSTANTS to 1.&lt;BR /&gt;&amp;nbsp;-We define a brand new target for ansixbi.lib and change the name to _ansixbi.lib&lt;BR /&gt;&amp;nbsp;-We recompile the lib and we linked&amp;nbsp; the newly created library file to our application.&lt;/P&gt;&lt;P&gt;We have written the follow code the test the new lib:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;#include &amp;lt;hidef.h&amp;gt; /* common defines and macros */&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;#include "derivative.h" /* derivative-specific definitions */&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;#include &amp;lt;string.h&amp;gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;#pragma DATA_SEG __GPAGE_SEG PAGED_RAM &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;volatile unsigned long l_paged = 0xAABBCCDD; // paged var&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;#pragma DATA_SEG DEFAULT &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;volatile unsigned long l_non_paged, x; // non paged var&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;void main(void) &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;{ &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;(void) memcpy(&amp;amp;l_non_paged, &amp;amp;l_paged, sizeof(l_non_paged)); &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;for(;;)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;{&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; x = l_paged;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; l_non_paged = x + l_paged; &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;}&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;We have add&amp;nbsp;&lt;SPAN&gt;-D__FAR_DATA in compiler command line&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;unfortunately, it does not work, the compiler gives the warning:&lt;BR /&gt;C1860: Pointer conversion: possible loss of data&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;l_paged&lt;/STRONG&gt; is located to 0xFB000'G&lt;BR /&gt;&lt;STRONG&gt;l_non_paged&lt;/STRONG&gt;&amp;nbsp;is located to 0x2FD0&lt;/P&gt;&lt;P&gt;When the addresses of variables are passing to c lib, memcpy gets 0x10002F;G for&amp;nbsp;&lt;STRONG&gt;l_paged&amp;nbsp;&lt;/STRONG&gt;and 0xD0FEC0'G for&amp;nbsp;&lt;STRONG&gt;l_non_paged.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;It looks as if the application is not aware that the new _ansixbi.lib waits for 24 addresses and feeds the lib with 16bit addresses&lt;/P&gt;&lt;P&gt;I have attached a small project and the recompiled lib&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 11:48:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/HCX12-c-lib-amp-paged-ram/m-p/1878957#M7931</guid>
      <dc:creator>Eric_t</dc:creator>
      <dc:date>2024-05-31T11:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: HCX12 c lib &amp; paged ram</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/HCX12-c-lib-amp-paged-ram/m-p/1879727#M7932</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me answer in general.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The message you got reports that the variable has different length of the address and the pointer was implicitly converted. If you want to have correct length I suggest you to step the code and check what is happening. The new project and copy/paste c and h files is faster than never ending solution of possible issues.&lt;/P&gt;
&lt;P&gt;In this case, it could be probably enough to use explicit conversions. However, in these cases I suggest always to be sure you use correct addressing mode of processing selected by compiler. Probably recompiling of the files is not enough because NEAR/SMALL project has NEAR default placement of variables (up to 64B address) and FAR/BANKED project uses paged addressing/pointers as default. However all accesses can be explicitly handled by near/far modifiers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe when you step the code you will see the issue of pointer usage and conversions.&lt;/P&gt;
&lt;P&gt;BW, regarding pointers and functions like memcpy, memmove, I suggest to create own functions if you have uncompatible addresses. The system can use Global, RPAGE or near addressing modes so it is easy to get error.&lt;/P&gt;
&lt;P&gt;These functions also uses “void” input parameter so I do not believe they are able to accept correctly input parameters of different formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the CW…when you use project wizard…&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Small memory model&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The Small memory model is best suited if both the code and the data do fit into the 64 kB address space.&lt;/P&gt;
&lt;P&gt;By default all variables and functions are accessed with 16 bit addresses. The compiler does support banked functions or paged variables in this memory model, however&lt;/P&gt;
&lt;P&gt;all accesses have to be explicitly handled.&lt;/P&gt;
&lt;P&gt;The small memory model should be used for all derivatives with less than 64k&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Banked memory model&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;“The Banked memory model is using banked function calls by default. The default data access however is still 16 bit.&lt;/P&gt;
&lt;P&gt;Because the overhead of the far function call is not very large, this memory model suits all applications with more than 64k code.&lt;/P&gt;
&lt;P&gt;Data paging can be used in the banked memory model, however all far objects and pointers to them have to be specially declared.”&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--------&lt;/P&gt;
&lt;P&gt;You also will see my “far” modifiers to be sure the variable is correctly compiled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to change memory model from near to banked I always suggest to create a new project for given model because there can be any issues which we are not able to locate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached examples of RAM addressing for XDT and one for XP. The XEP is a different family but principle of addressing is the same. The example shows how to use RAM linearly by GPAGE instructions. (look also into prm file)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Ladislav&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 09:44:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/HCX12-c-lib-amp-paged-ram/m-p/1879727#M7932</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2024-06-03T09:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: HCX12 c lib &amp; paged ram</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/HCX12-c-lib-amp-paged-ram/m-p/1889253#M7934</link>
      <description>&lt;P&gt;I have found the problem.&lt;BR /&gt;I forgot to change the access paths to the local library.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Eric_t_0-1718694531868.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/284589i511EBC1E1FC2F6C6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Eric_t_0-1718694531868.png" alt="Eric_t_0-1718694531868.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now the project is aware of the far ansi lib&lt;/P&gt;&lt;P&gt;However, the %s of sprintf is not working without casting&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;volatile unsigned char buff[20], model[4];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(void) sprintf(buff, "%s", /*(unsigned char *far)*/ model); // needs casting &lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I have attached a small project that demostate the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 07:40:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/HCX12-c-lib-amp-paged-ram/m-p/1889253#M7934</guid>
      <dc:creator>Eric_t</dc:creator>
      <dc:date>2024-06-18T07:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: HCX12 c lib &amp; paged ram</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/HCX12-c-lib-amp-paged-ram/m-p/1890435#M7936</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;as I wrote before.&lt;/P&gt;
&lt;P&gt;The easiest way is to open new project and copy all c and h files to it.&lt;/P&gt;
&lt;P&gt;You will avoid all unexpected errors.&lt;/P&gt;
&lt;P&gt;We have done it always in this way because there can anytime appear any new issue because libraries incompatibility.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Ladislav&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2024 13:25:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/HCX12-c-lib-amp-paged-ram/m-p/1890435#M7936</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2024-06-19T13:25:10Z</dc:date>
    </item>
  </channel>
</rss>

