<?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 problem when access paged ram variable by pointer in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068044#M17280</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My mcu is MC9S12XE.&lt;/P&gt;&lt;P&gt;I have defined a variable named such as msg_buffer in the PAGED RAM,and it's actually allocated address is F91000.I want to put data into this buffer using pointer,but doesn't work.Codes look like this:&lt;/P&gt;&lt;P&gt;pbsor = msg;&lt;/P&gt;&lt;P&gt;pbdst = msg_buffer;&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; size; ++i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;*pbdst++ = *pbsor++;&lt;/P&gt;&lt;P&gt;But when i defined pbdst with prefix '__far',it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i use prefix '__far' in the function which get data from msg buffer,it doesn't work.Codes look like this:&lt;/P&gt;&lt;P&gt;pbsor = msg_buffer;&lt;/P&gt;&lt;P&gt;pbdst = msg;&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; size; ++i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;*pbdst++ = *pbsor;&lt;/P&gt;&lt;P&gt;But when i defiend pbsor without prefix '__far',it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why does it execute like this?By the way,the variable msg allocated in the stack,and stack is allocated in the UNPAGEED RAM(0x2000~0x3FFF).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 May 2020 06:16:57 GMT</pubDate>
    <dc:creator>everkimage</dc:creator>
    <dc:date>2020-05-25T06:16:57Z</dc:date>
    <item>
      <title>problem when access paged ram variable by pointer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068044#M17280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My mcu is MC9S12XE.&lt;/P&gt;&lt;P&gt;I have defined a variable named such as msg_buffer in the PAGED RAM,and it's actually allocated address is F91000.I want to put data into this buffer using pointer,but doesn't work.Codes look like this:&lt;/P&gt;&lt;P&gt;pbsor = msg;&lt;/P&gt;&lt;P&gt;pbdst = msg_buffer;&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; size; ++i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;*pbdst++ = *pbsor++;&lt;/P&gt;&lt;P&gt;But when i defined pbdst with prefix '__far',it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i use prefix '__far' in the function which get data from msg buffer,it doesn't work.Codes look like this:&lt;/P&gt;&lt;P&gt;pbsor = msg_buffer;&lt;/P&gt;&lt;P&gt;pbdst = msg;&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; size; ++i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;*pbdst++ = *pbsor;&lt;/P&gt;&lt;P&gt;But when i defiend pbsor without prefix '__far',it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why does it execute like this?By the way,the variable msg allocated in the stack,and stack is allocated in the UNPAGEED RAM(0x2000~0x3FFF).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2020 06:16:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068044#M17280</guid>
      <dc:creator>everkimage</dc:creator>
      <dc:date>2020-05-25T06:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: problem when access paged ram variable by pointer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068045#M17281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;better than presented code is full, short, functional example. It is better to see all dependencies.&lt;/P&gt;&lt;P&gt;I have attached an example (SW-XEP100-RAM-addressing-v1_0-CW51.zip) I prepared few days ago. It shows you how to + some important notes like _D_FARDATA definition.&lt;/P&gt;&lt;P&gt;I believe it will help you. (Otherwise, I would prefer to get short, issue highlighting project)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ladislav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2020 07:22:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068045#M17281</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2020-05-25T07:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: problem when access paged ram variable by pointer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068046#M17282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply very much.&lt;/P&gt;&lt;P&gt;But my situation is some different with normal principle.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to copy data in Unpaged RAM into Paged RAM,normally i need use prefix '__far' to define my pointer toPaged RAM,but it does not work.However use a pointer without any prefix can copy the data correctly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2020 09:48:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068046#M17282</guid>
      <dc:creator>everkimage</dc:creator>
      <dc:date>2020-05-25T09:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: problem when access paged ram variable by pointer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068047#M17283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;As I wrote before "better than presented code is full, short, functional example. It is better to see all dependencies."&lt;/P&gt;&lt;P&gt;I do not want to speculate what is where and what could be where.&lt;BR /&gt;I need to have full project to have exactly visible project setup and variables definitions.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ladislav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2020 14:59:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068047#M17283</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2020-05-25T14:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: problem when access paged ram variable by pointer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068048#M17284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now i know how to cause the problem exactly.As show in the prm file of project:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;default setting is:&lt;/P&gt;&lt;P&gt;XGATE_DATA INTO RAM_F8, RAM_F9, RAM_FA, RAM_FB&lt;/P&gt;&lt;P&gt;PAGED_DATA INTO RAM_FD, RAM_FC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;change it to:&lt;/P&gt;&lt;P&gt;XGATE_DATA INTO RAM_F8&lt;/P&gt;&lt;P&gt;PAGED_DATA INTO RAM_F9, RAM_FA, RAM_FB, RAM_FD, RAM_FC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then the access to the global variable allocate at RAM_F9 will be failed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I forget to add prefix 'far' back to code,but even if i add it back to local variable pddst,structure member size also can not be access correctely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So i use a structure pointer to point global variable with prefix 'far',and everything is ok.Is it mean that it should use 'far' pointer to access a PAGED RAM allocated variable?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2020 06:16:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068048#M17284</guid>
      <dc:creator>everkimage</dc:creator>
      <dc:date>2020-05-27T06:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: problem when access paged ram variable by pointer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068049#M17285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your problem you need to and forgot to use far or proper #pragma memory qualifiers. Once it is done properly, compiler will emit warnings each time you use wrong pointers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// variables in paged memory have to be always either:&lt;BR /&gt;// 1) be put into qualified __R/E/GPAGE_SEG memory. This will let compiler know &lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; memory is paged and how this paged memory is to be accesses, using RPAGE/GPAGE/etc addressing&lt;BR /&gt;// 2) use far keyword&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Don't forget as well&amp;nbsp;when exporting data from paged memory to other C files to use&lt;/P&gt;&lt;P&gt;// correct #pragma with the the same&amp;nbsp;__RPAGE_SEG/__GPAGE_SEG attribute, or far keyword&lt;BR /&gt;// in header file! #pragma often is better, since it specifies which way compiler should access data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#pragma push&lt;BR /&gt;#pragma DATA_SEG __RPAGE_SEG PAGED_RAM&lt;BR /&gt;MSGBUF gst_mb;&lt;BR /&gt;#pragma pop&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2020 14:34:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/problem-when-access-paged-ram-variable-by-pointer/m-p/1068049#M17285</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2020-05-27T14:34:38Z</dc:date>
    </item>
  </channel>
</rss>

