<?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>S12 / MagniV MicrocontrollersのトピックRe: Copying info between RAM pages</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180603#M6556</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;FONT size="2"&gt;The problem i got before using a regular assigment like you suggested (StructA.fielda= StructB.fieldb) is that the RPAGE switching is being done only once so the system was ready to write into page 0xF8 it was trying to read the value of StructB also from this page and not from 0xFD.&lt;BR /&gt;&lt;BR /&gt;I realized that by assigning the value of the StructA to a local variable it would keep this value in the stack before switching to RPAGE = 0xF8, and then the system switchs to page 0xF8 and extracts the value to be written from the stack and not from a RAM access, however this forced me to set the RPAGE back to 0xFD once the assigment is done or the code will get lost.&lt;BR /&gt;&lt;BR /&gt;As i told you, i was able to make it work with the example i gave you before, but now&lt;/FONT&gt; &lt;FONT size="2"&gt;what i would like to do is that instead of giving the address as a magic number ( 0xf8000)&lt;/FONT&gt; &lt;FONT size="2"&gt;i want to do it with the "&amp;amp;" operator, something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;"&lt;/FONT&gt;&lt;FONT size="2"&gt;unsigned char * __far pointerStructA = (unsigned char* __far) &amp;amp;StructA;"&lt;/FONT&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;However, when i do this, pointerStructA is set to 0x7FC000 and not to the 0xF8000 as it should be.&lt;BR /&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Jan 2008 23:40:16 GMT</pubDate>
    <dc:creator>dborras</dc:creator>
    <dc:date>2008-01-18T23:40:16Z</dc:date>
    <item>
      <title>Copying info between RAM pages</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180598#M6551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Hello&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;I wondering if someone can help me, i have a big problem withe the Paged RAM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;I have two different structures, each on different RAM pages, one (StructureA) in RPAGE 0xF8 and the other (SturctureB) in RPAGE 0xFD. I need to copy some information from StructureB into StructureA.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;I check at my compiler options and everything looks just fine, i set StructureA at RPAGE 0xF8 using the #PRAGMA directive and the memory map shows it in correct location.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;However..... i have tried several ways to do this operation and i haven't been able to do so, i'm not quite an expert on 9s12x so i don't know if i'm doing this fine? Can someone explain me how to do this?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Maybe a quick example on how to implement it?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2008 07:49:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180598#M6551</guid>
      <dc:creator>dborras</dc:creator>
      <dc:date>2008-01-18T07:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Copying info between RAM pages</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180599#M6552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;A simple assignment should do it.&lt;BR /&gt;Either assign all the fileds you need or just assign a complete struct if all the fields have to be copied.&lt;BR /&gt;&lt;BR /&gt;Can you show a complete sample of what you tried?&lt;BR /&gt;Best if the sample is compilable on its own.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2008 08:32:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180599#M6552</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-01-18T08:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copying info between RAM pages</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180600#M6553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I tried that and didn't work,&lt;BR /&gt;&lt;BR /&gt;I made work by doing the following&lt;BR /&gt;&lt;FONT color="#6633CC"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;B&gt;&lt;I&gt;&lt;FONT size="1"&gt;&lt;FONT color="#6633CC"&gt;void &lt;FONT color="#330000"&gt;foo(&lt;/FONT&gt;unsigned char &lt;FONT color="#330000"&gt;indexA,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT size="1"&gt;&lt;FONT color="#6633CC"&gt;unsigned char &lt;FONT color="#330000"&gt;indexB&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="1"&gt;&lt;FONT color="#6633CC"&gt;&lt;FONT color="#330000"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&amp;nbsp; _far &lt;FONT color="#6633FF"&gt;unsigned char&lt;/FONT&gt; *pointerStructA = (_far unsigned char*) 0xf8000;&lt;BR /&gt;&amp;nbsp;&lt;/FONT&gt; &lt;FONT size="1"&gt;&lt;FONT color="#6633FF"&gt;unsigned char&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *pointerStructB = 0;&lt;BR /&gt;&amp;nbsp;&lt;/FONT&gt; &lt;FONT size="1"&gt;&lt;FONT color="#6633FF"&gt;unsigned char&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data = 0;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; pointerStructB = (unsigned char*)&amp;amp;StructB;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; data = pointerStructB[indexB];&lt;BR /&gt;&amp;nbsp; pointerStructA[indexA] = data;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#6633FF"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt;However, i have another question, i tried to assign the address where pointerStructA should be just like a did for pointerStructB and i was not able to do it, it should be 0xf8000 but everytime i did i was always setting it to a flash address, i can't recall which one was it.&lt;BR /&gt;&lt;BR /&gt;Why is that? how do i make the system able to extract the global address where a variable is allocated and not the logical one? i tried declaring the variable as far instead of using the pragma directive but didn't work!&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2008 08:51:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180600#M6553</guid>
      <dc:creator>dborras</dc:creator>
      <dc:date>2008-01-18T08:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Copying info between RAM pages</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180601#M6554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&amp;nbsp; unsigned char * far pointerStructA = (unsigned char * far)0xf8000;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2008 15:11:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180601#M6554</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2008-01-18T15:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Copying info between RAM pages</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180602#M6555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Both the #pragma and the __far qualifiers are needed as they serve a different purpose.&lt;BR /&gt;The "#prgama DATA_SEG __RPAGE_SEG XYZ" places the variable in the corresponding section and it also tells the compiler to access the variable with rpage access.&lt;BR /&gt;The __far pointer qualifier (should be after the * for every pointer) tells the compiler that this is a pointer capable of accessing __far objects.&lt;BR /&gt;&lt;BR /&gt;With the assumption that&amp;nbsp; StructB is allocated correspondingly in a #pragma with a __RPAGE_SEG&amp;nbsp; or __GPAGE_SEG qualifier, I would write it like this.&lt;BR /&gt;StructA should be just the same.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;B&gt;&lt;BR /&gt;&lt;/B&gt;&lt;B&gt;&lt;BR /&gt;&lt;I&gt;&lt;/I&gt;&lt;/B&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;void foo(unsigned char indexA, unsigned char indexB)  unsigned char * __far pointerStructA = (unsigned char* __far) 0xf8000;  unsigned char *__far pointerStructB;  unsigned char         data = 0;  pointerStructB = (unsigned char*__far)&amp;amp;StructB;  data = pointerStructB[indexB];  pointerStructA[indexA] = data;}



&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;Of course it's a lot simpler to write StructA.fielda= StructB.fieldb, if the pragmas are correct, that should work fine too. If it does not for you, please show a complete sample. Also consider using two arrays, if that is the normal way accessing your data. Then ArrayA[indexA]= ArrayB[indexB] should work just fine.&lt;BR /&gt;&lt;BR /&gt;Note that in your sample, you did not use a __far pointer for the pointerStructB, I wonder why that actually worked.&lt;BR /&gt;&lt;BR /&gt;Also things I would really suggest to look into are the following two technical notes:&lt;BR /&gt;&lt;BR /&gt;TN 238- HCS12X - Data Definition&lt;BR /&gt;TN 240- HCS12X - Accessing Data&lt;BR /&gt;&lt;BR /&gt;TN's can be downloaded separately, they are not in the default installation, as far as I know.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;I&gt;&lt;FONT size="1"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:30:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180602#M6555</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2020-10-29T09:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Copying info between RAM pages</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180603#M6556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;FONT size="2"&gt;The problem i got before using a regular assigment like you suggested (StructA.fielda= StructB.fieldb) is that the RPAGE switching is being done only once so the system was ready to write into page 0xF8 it was trying to read the value of StructB also from this page and not from 0xFD.&lt;BR /&gt;&lt;BR /&gt;I realized that by assigning the value of the StructA to a local variable it would keep this value in the stack before switching to RPAGE = 0xF8, and then the system switchs to page 0xF8 and extracts the value to be written from the stack and not from a RAM access, however this forced me to set the RPAGE back to 0xFD once the assigment is done or the code will get lost.&lt;BR /&gt;&lt;BR /&gt;As i told you, i was able to make it work with the example i gave you before, but now&lt;/FONT&gt; &lt;FONT size="2"&gt;what i would like to do is that instead of giving the address as a magic number ( 0xf8000)&lt;/FONT&gt; &lt;FONT size="2"&gt;i want to do it with the "&amp;amp;" operator, something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;"&lt;/FONT&gt;&lt;FONT size="2"&gt;unsigned char * __far pointerStructA = (unsigned char* __far) &amp;amp;StructA;"&lt;/FONT&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;However, when i do this, pointerStructA is set to 0x7FC000 and not to the 0xF8000 as it should be.&lt;BR /&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2008 23:40:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180603#M6556</guid>
      <dc:creator>dborras</dc:creator>
      <dc:date>2008-01-18T23:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Copying info between RAM pages</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180604#M6557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;If the simple assignment did not work and if the address gets set to a flash one when you use the address operator, then I suspect that something in the way you define or declare the &lt;FONT size="2"&gt;StructA/&lt;/FONT&gt;&lt;FONT size="2"&gt;StructB variables is wrong, or that there is a problem in the prm file.&lt;BR /&gt;Can you provide a complete sample showing the problem? I understand that it does not work for you so far, but the parts you showed so far did look ok, but there is plenty of not shown stuff which may really contain the problem. Did you look up the TNs?&lt;BR /&gt;&lt;BR /&gt;Also I don't understand this part:&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;&amp;gt;however this forced me to set the RPAGE back to 0xFD once the assignment is done or the code will get lost.&lt;BR /&gt;How can the code get lost by changing RPAGE?&lt;BR /&gt;If that code gets executed by an interrupt handler, make sure it generates the needed staking of the page registers (I think by using the -CRPGAGE option)&lt;BR /&gt;For the compiler the RPAGE register content is volatile, its undefined after any function call, so normally RPAGE does not need to be backed up (with the exception being interrupt handlers).&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;Daniel&lt;BR /&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jan 2008 02:22:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Copying-info-between-RAM-pages/m-p/180604#M6557</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-01-19T02:22:47Z</dc:date>
    </item>
  </channel>
</rss>

