<?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 9S12XEP100: how to access variable in RPAGE? in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/9S12XEP100-how-to-access-variable-in-RPAGE/m-p/484298#M12054</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to assign many variables in the multiple RPAGEs (due to total number of vars exceed the one RPAGE size)&lt;/P&gt;&lt;P&gt;To access a var in RPAGE, the Freescale technical document TN238 shows as follows:&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG __RPAGE_SEG PAGED_RAM&lt;/P&gt;&lt;P&gt;unsigned char rub_far_var;&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG DEFAULT&lt;/P&gt;&lt;P&gt; A pointer pointing to such a variable can be defined as follows:&lt;/P&gt;&lt;P&gt;unsigned char * __rptr ptr_on_far_var;&lt;/P&gt;&lt;P&gt;Then assign the pointer to this var&lt;/P&gt;&lt;P&gt;ptr_on_far_var = &amp;amp;rub_far_var;&lt;/P&gt;&lt;P&gt;if you want to access this var, you need to use this pointer.&lt;/P&gt;&lt;P&gt;ptr_on_far_var = 5;&lt;/P&gt;&lt;P&gt;if (ptr_on_far_var == 5)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;My question is that can I just assign __far var instead? &lt;/P&gt;&lt;P&gt;all I need to do is as follows:&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG PAGED_RAM&lt;/P&gt;&lt;P&gt;unsigned char __far rub_far_var;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rub_far_var = 5;&lt;/P&gt;&lt;P&gt;if (ptr_on_far_var == 5)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;the compiler should know where to allocate the var in the RPAGE, retrieve the var from the correct RPAGE&lt;/P&gt;&lt;P&gt;and function the same as __rptr. So I don't need to assign an extra pointer for every variable in the code.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to work. I would like a confirmation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Feb 2016 22:58:50 GMT</pubDate>
    <dc:creator>precisionman</dc:creator>
    <dc:date>2016-02-03T22:58:50Z</dc:date>
    <item>
      <title>9S12XEP100: how to access variable in RPAGE?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/9S12XEP100-how-to-access-variable-in-RPAGE/m-p/484298#M12054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to assign many variables in the multiple RPAGEs (due to total number of vars exceed the one RPAGE size)&lt;/P&gt;&lt;P&gt;To access a var in RPAGE, the Freescale technical document TN238 shows as follows:&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG __RPAGE_SEG PAGED_RAM&lt;/P&gt;&lt;P&gt;unsigned char rub_far_var;&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG DEFAULT&lt;/P&gt;&lt;P&gt; A pointer pointing to such a variable can be defined as follows:&lt;/P&gt;&lt;P&gt;unsigned char * __rptr ptr_on_far_var;&lt;/P&gt;&lt;P&gt;Then assign the pointer to this var&lt;/P&gt;&lt;P&gt;ptr_on_far_var = &amp;amp;rub_far_var;&lt;/P&gt;&lt;P&gt;if you want to access this var, you need to use this pointer.&lt;/P&gt;&lt;P&gt;ptr_on_far_var = 5;&lt;/P&gt;&lt;P&gt;if (ptr_on_far_var == 5)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;My question is that can I just assign __far var instead? &lt;/P&gt;&lt;P&gt;all I need to do is as follows:&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG PAGED_RAM&lt;/P&gt;&lt;P&gt;unsigned char __far rub_far_var;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rub_far_var = 5;&lt;/P&gt;&lt;P&gt;if (ptr_on_far_var == 5)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;the compiler should know where to allocate the var in the RPAGE, retrieve the var from the correct RPAGE&lt;/P&gt;&lt;P&gt;and function the same as __rptr. So I don't need to assign an extra pointer for every variable in the code.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to work. I would like a confirmation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Feb 2016 22:58:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/9S12XEP100-how-to-access-variable-in-RPAGE/m-p/484298#M12054</guid>
      <dc:creator>precisionman</dc:creator>
      <dc:date>2016-02-03T22:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: 9S12XEP100: how to access variable in RPAGE?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/9S12XEP100-how-to-access-variable-in-RPAGE/m-p/484299#M12055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can access variables in paged ram directly. far keyword or __rptr pointers are not necessary for this. Then only thing compiler needs is rounding paged variables with required pragmas, BOTH, in C file where variables are defined, AND in H file, in case variables are exported to other C files with extern keyword. Compiler needs to see #pragma's to know where to allocate variables (in PAGED_RAM or not), and how to access variables __RPAGE_SEG for access via R-page window at 0x1000..0x1FFF or __GPAGE_SEG for access using global addressing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in H file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG __RPAGE_SEG PAGED_RAM&lt;/P&gt;&lt;P&gt;extern int my_rpage_var;&lt;/P&gt;&lt;P&gt;// and more R-page vars here&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in C file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG __RPAGE_SEG PAGED_RAM&lt;/P&gt;&lt;P&gt;int my_rpage_var; &lt;/P&gt;&lt;P&gt;// and more R-page vars here&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;foo()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; my_rpage_var = 5;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you are going to use more R-pages, be aware you need to care about default -PSegxxx setting, which is -PSegNonDef and is not compatible with R-page addressing of multipage PAGED_RAM PLACEMENT. Your choices are&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Add -PSegObj to compiler command line and use __RPAGE_SEG with PAGED_RAM. Without this compiler may fail switching RPAGE when necessary to access object on different RPAGE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Using __GPAGE_SEG instead of __RPAGE_SEG you don't need to add -PSegObj. This would be fine with global addressing, since even 64k of RAM fits single G-page, so default more speed effective -PSegNonDef would be fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Since R-page addressing with default -PSegNonDef could be more effective (more CPU instructions choices for non-global addressing), instead of using PAGED_RAM placement, you need to define dedicated placements for each R-page. Say RAMPAGE_F8, RAMPAGE_F9, etc, and use only these placements with __RPAGE_SEG. You will then start allocating paged variable to RAMPAGE_F8 first, then, when linker reports lack of space in RAMPAGE_F8, you will place variables to RAMPAGE_F9 etc.. This would be safe and also faster with default -PSegNonDef&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2016 09:58:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/9S12XEP100-how-to-access-variable-in-RPAGE/m-p/484299#M12055</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2016-02-04T09:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: 9S12XEP100: how to access variable in RPAGE?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/9S12XEP100-how-to-access-variable-in-RPAGE/m-p/484300#M12056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Edward,&lt;/P&gt;&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;P&gt;what if I remove the _RPAGE_SEG and just declare #pragma DATA_SEG PAGED_RAM. Now I want to pass that var or a pointer to the foo() function.&lt;/P&gt;&lt;P&gt;foo(my_rpage_var)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this var or pointer need to add __far keyword? it did not work if I don't include __far.&lt;/P&gt;&lt;P&gt;Thx, Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2016 18:29:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/9S12XEP100-how-to-access-variable-in-RPAGE/m-p/484300#M12056</guid>
      <dc:creator>precisionman</dc:creator>
      <dc:date>2016-02-04T18:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: 9S12XEP100: how to access variable in RPAGE?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/9S12XEP100-how-to-access-variable-in-RPAGE/m-p/484301#M12057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can avoid __RPAGE_SEG and __GPAGE_SEG, but then paged variables and pointer to paged variables have to be used with far (__far) keyword. Compiler has to know that particular variable is "not easy to access". Either it must see var declared/defined below the #pragma XXX_SEG __RPAGE_SEG&amp;nbsp; (or __GPAGE_SEG), or variable has to be defined/declared with far keyword.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function taking pointer to paged variable, also pointers which may point to paged variable need to use far keyword. Or __rptr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Edward&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2016 20:58:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/9S12XEP100-how-to-access-variable-in-RPAGE/m-p/484301#M12057</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2016-02-04T20:58:50Z</dc:date>
    </item>
  </channel>
</rss>

