<?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: Need Help Sharing Pointers Between XGATE and S12X</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178500#M6387</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is "sizeof(&lt;FONT size="2"&gt;@&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" size="2"&gt;&lt;FONT color="#000080" size="2"&gt;far&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT size="2"&gt;@gpage&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" size="2"&gt;&lt;FONT color="#000080" size="2"&gt;unsigned&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" size="2"&gt;&lt;FONT color="#000080" size="2"&gt;char&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff" size="2"&gt;&lt;FONT color="#0000ff" size="2"&gt;*&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="2"&gt;)" for the cosmic compiler? Does the cosmic compiler reserve 3 or 4 bytes for far pointers?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Are the offsets (and sizes) of all the structs members the same for the S12X and the XGATE compiler? You could check that at compile time by computing it with the ANSI offsetof macro and comparing it to the expected value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What address values do you get in the structure when reading them from the S12X or from the XGATE? What is in memory? What do you expect, what do you find?&lt;/P&gt;&lt;P&gt;Is the explicit cast in the initialization necessary?&lt;/P&gt;&lt;P&gt;I'm also not sure what you refer to with "t&lt;FONT size="2"&gt;he array address", which appears correct to the XGATE, you mean the address from which the&lt;/FONT&gt; &lt;FONT size="2"&gt;port_address field&lt;/FONT&gt; &lt;FONT size="2"&gt;is read from?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end, if the goal is to point to different port addresses, then the simplest solution is probably just to use S12X near pointers as the addresses of all peripherials are the same for the XGATE and the S12X (for any pointer type...). Only addresses of RAM or FLASH locations are different in between the two cores and need the special handling.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 May 2009 12:54:36 GMT</pubDate>
    <dc:creator>CompilerGuru</dc:creator>
    <dc:date>2009-05-06T12:54:36Z</dc:date>
    <item>
      <title>Need Help Sharing Pointers Between XGATE and S12X</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178499#M6386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;All,&lt;BR /&gt;&lt;BR /&gt;I have read the following threads regarding sharing pointers between S12X and XGATE&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;:&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;http&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;:&lt;/STRONG&gt;&lt;EM style=": ; color: #008000; font-size: 2;"&gt;//forums.freescale.com/freescale/board/message?board.id=CW816COMM&amp;amp;message.id=5241&amp;amp;query.id=111480#M5241&lt;BR /&gt;&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fforums.freescale.com%2Ffreescale%2Fboard%2Fmessage%3Fboard.id%3DCW816COMM%26message.id%3D3870%26query.id%3D111544%23M3870" rel="nofollow" target="_blank"&gt;http&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;:&lt;/STRONG&gt;&lt;EM style=": ; color: #008000; font-size: 2;"&gt;//forums.freescale.com/freescale/board/message?board.id=CW816COMM&amp;amp;message.id=3870&amp;amp;query.id=111544#M3870&lt;/EM&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;I have attempted to implement the method described in the first forum post&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;Thus&lt;/SPAN&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;far&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;, I have not had any luck&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;BR /&gt;I am attempting to create an array of configuration structures that contain pointers to I&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;/&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;O ports&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;For convenience, I want this array to be accessed by both cores and would like to avoid creating two copies of the same array of structures.&amp;nbsp;&lt;/SPAN&gt; &lt;SPAN style="font-size: 2;"&gt;Here are snippets of my first attempt&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;BR /&gt;Included by XGATE&lt;/SPAN&gt; &lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;&amp;amp;&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;S12X source code&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;:&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;pulseo_private&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;h&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;typedef&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;struct&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #008080; font-size: 2;"&gt;{&lt;/SPAN&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #ff0000; font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;P&gt;&lt;SPAN style=": ; color: #ff0000; font-size: 2;"&gt;#ifdef&lt;/SPAN&gt; &lt;SPAN style="font-size: 2;"&gt;CPU12X&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/*define structure for CPU12X*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;driver_type;&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/* driver type, pwm/onoff*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;driver_type_align;&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/* alignment padding*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;port_address_align;&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/* alignment padding*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;@&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;far&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;@gpage&lt;/SPAN&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;*&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;port_address;&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/* port address*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #ff0000; font-size: 2;"&gt;#else&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/*structure definition for XGATE::allows sharing of pointers*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;driver_type;&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/* driver type*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;driver_type_align;&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/* alignment padding*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;port_address_align;&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/* alignment padding for port address*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;port_address_pg;&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/*page for global pointer port_address*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;@&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;far&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;@gpage&lt;/SPAN&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;*&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;port_address&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;/*port address*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #ff0000; font-size: 2;"&gt;#endif&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;SPAN style=": ; color: #008080; font-size: 2;"&gt;}&lt;/SPAN&gt; &lt;SPAN style="font-size: 2;"&gt;pulseo_init_port_map_t;&lt;BR /&gt;&lt;BR /&gt;Compiled by S12X compiler&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;:&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;pulseo_mod_globals&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;c&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;const&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;pulseo_init_port_map_t pulseo_chan_map[]&lt;/SPAN&gt; &lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;=&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #008080; font-size: 2;"&gt;{&lt;/SPAN&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;EM style=": ; color: #008000; font-size: 2;"&gt;&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;P&gt;&lt;EM style=": ; color: #008000; font-size: 2;"&gt;/*Init CHANNEL_01*/&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #808000; font-size: 2;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 2;"&gt;,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #808000; font-size: 2;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 2;"&gt;,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #808000; font-size: 2;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 2;"&gt;,&lt;BR /&gt;(@&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;far&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;@gpage&lt;/SPAN&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;*&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;)&amp;amp;PORTP,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #008080; font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style=": ; color: #008080; font-size: 2;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="font-size: 2;"&gt;;&lt;BR /&gt;&lt;BR /&gt;Compiled by XGATE compiler&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;:&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;temp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;unsigned&lt;/STRONG&gt; &lt;STRONG style=": ; color: #000080; font-size: 2;"&gt;char&lt;/STRONG&gt; &lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;*&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;temp1;&lt;BR /&gt;temp&lt;/SPAN&gt; &lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;=&lt;/STRONG&gt; &lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;*&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;(pulseo_chan_map[driver_index]&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;port_address);&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;//deference for test&lt;BR /&gt;&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;temp1&lt;/SPAN&gt; &lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;=&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;(hal_u08_t&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;*&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;)(pulseo_chan_map[driver_index]&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;port_address);&lt;/SPAN&gt; &lt;EM style=": ; color: #008000; font-size: 2;"&gt;//get address for test&lt;BR /&gt;&lt;/EM&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;The array address appears correctly to the XGATE, but I am unable to access structure members correctly&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&amp;nbsp; I find both the pointer address and data value are incorrect&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt; &lt;SPAN style="font-size: 2;"&gt;Please note, this is built using the COSMIC S12X and XGATE compilers with the MC9S12XEQ384 controller&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 2;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;Any advice would be greatly appeciated (except to switch from Cosmic to Codewarrior &lt;SPAN aria-label="Wink" class="emoticon-inline emoticon_wink" style="height:16px;width:16px;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;Thanks in Advance,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;Dave&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2009 07:45:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178499#M6386</guid>
      <dc:creator>DaveSubert</dc:creator>
      <dc:date>2009-05-06T07:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help Sharing Pointers Between XGATE and S12X</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178500#M6387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is "sizeof(&lt;FONT size="2"&gt;@&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" size="2"&gt;&lt;FONT color="#000080" size="2"&gt;far&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT size="2"&gt;@gpage&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" size="2"&gt;&lt;FONT color="#000080" size="2"&gt;unsigned&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" size="2"&gt;&lt;FONT color="#000080" size="2"&gt;char&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff" size="2"&gt;&lt;FONT color="#0000ff" size="2"&gt;*&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="2"&gt;)" for the cosmic compiler? Does the cosmic compiler reserve 3 or 4 bytes for far pointers?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Are the offsets (and sizes) of all the structs members the same for the S12X and the XGATE compiler? You could check that at compile time by computing it with the ANSI offsetof macro and comparing it to the expected value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What address values do you get in the structure when reading them from the S12X or from the XGATE? What is in memory? What do you expect, what do you find?&lt;/P&gt;&lt;P&gt;Is the explicit cast in the initialization necessary?&lt;/P&gt;&lt;P&gt;I'm also not sure what you refer to with "t&lt;FONT size="2"&gt;he array address", which appears correct to the XGATE, you mean the address from which the&lt;/FONT&gt; &lt;FONT size="2"&gt;port_address field&lt;/FONT&gt; &lt;FONT size="2"&gt;is read from?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end, if the goal is to point to different port addresses, then the simplest solution is probably just to use S12X near pointers as the addresses of all peripherials are the same for the XGATE and the S12X (for any pointer type...). Only addresses of RAM or FLASH locations are different in between the two cores and need the special handling.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2009 12:54:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178500#M6387</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2009-05-06T12:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help Sharing Pointers Between XGATE and S12X</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178501#M6388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply.&amp;nbsp; Here are the answers to your questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;What is "sizeof(&lt;FONT size="2"&gt;@&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" size="2"&gt;&lt;FONT color="#000080" size="2"&gt;far&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT size="2"&gt;@gpage&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" size="2"&gt;&lt;FONT color="#000080" size="2"&gt;unsigned&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" size="2"&gt;&lt;FONT color="#000080" size="2"&gt;char&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff" size="2"&gt;&lt;FONT color="#0000ff" size="2"&gt;*&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="2"&gt;)" for the cosmic compiler? Does the cosmic &amp;gt;&amp;gt;compiler reserve 3 or 4 bytes for far pointers?&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think we have a winner!&amp;nbsp; Cosmic defines them as 4 bytes.&amp;nbsp; I dropped the ball here, in other forum posts, I read far pointers are 3 bytes, but that's for CodeWarrior....not COSMIC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This also further explains why the definition of hal_pulseo_chan_map was messed up in the list file.&amp;nbsp; There was an additional byte I could not account for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Today I learned something extremely valuable about compilers.&amp;nbsp; I was under the impression that the pointer definitions would be the same since the generated code is for the same processor.&amp;nbsp; Not&lt;/P&gt;&lt;P&gt;the case.&amp;nbsp; I obviously have a lot to learn about compilers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;Are the offsets (and sizes) of all the structs members the same for the S12X and the XGATE &amp;gt;&amp;gt;compiler? You could check that at compile time by computing it with the ANSI offsetof macro and &amp;gt;&amp;gt;comparing it to the expected value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; No point in answering this question.....I'll have to change the definitions anyway.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;What address values do you get in the structure when reading them from the S12X or from the &amp;gt;&amp;gt;XGATE? What is in memory? What do you expect, what do you find?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S12X&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp = 0x00&amp;nbsp; (correct/expected/verified location in memory by using debugger)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;temp1 = &amp;nbsp;0x258 (correct/expected/verified location in memory by using debugger)&lt;/P&gt;&lt;P&gt;XGATE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp = 0xFF&amp;nbsp; (incorrect)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp1 = 0x0002 (incorrect)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;Is the explicit cast in the initialization necessary?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried this code with and without the cast and it doesn't work.&amp;nbsp; Also, the compiler manual calls&amp;nbsp;&amp;nbsp;&amp;nbsp; out the requirement for declaring a&amp;nbsp;global pointer&amp;nbsp;as @far @gpage when accessable via the GPAGE register.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;I'm also not sure what you refer to with "t&lt;FONT size="2"&gt;he array address", which appears correct to the XGATE, &amp;gt;&amp;gt;you mean the address from which the&lt;/FONT&gt; &lt;FONT size="2"&gt;port_address field&lt;/FONT&gt; &lt;FONT size="2"&gt;is read from?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually no.&amp;nbsp; Let me explain.&amp;nbsp; I set a pointer in the XGATE code to&amp;nbsp;point to the&amp;nbsp;array p&lt;FONT size="2"&gt;ulseo_chan_map (just to test the&lt;/FONT&gt; &lt;FONT size="2"&gt;address).&amp;nbsp; The&amp;nbsp;XGATE code reads&amp;nbsp;the pulseo_chan_map&amp;nbsp;&lt;/FONT&gt;&lt;FONT size="2"&gt;address&amp;nbsp;as 0x0F4E.&amp;nbsp;&lt;/FONT&gt; &lt;FONT size="2"&gt;This value is correct, since the&lt;/FONT&gt; &lt;FONT size="2"&gt;output *.MAP file shows the address of&amp;nbsp;&lt;/FONT&gt;&lt;FONT size="2"&gt;pulseo_chan_map as&lt;/FONT&gt; &lt;FONT size="2"&gt;0x780F4E.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;In the end, if the goal is to point to different port addresses, then the simplest solution is probably &amp;gt;&amp;gt;just to use S12X near pointers as the addresses of all peripherials are the same for the XGATE and &amp;gt;&amp;gt;the S12X (for any pointer type...). Only addresses of RAM or FLASH locations are different in &amp;gt;&amp;gt;between the two cores and need the special handling.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried this approach before beginning this forum post.&amp;nbsp; On the S12X side I created the pulseo_chan_map array without defining a&amp;nbsp;separate definition for the XGATE and also without forcing the&amp;nbsp;global pointer via @far @gpage.&amp;nbsp; The XGATE code was also unable to access the structure members properly.&amp;nbsp; I was observing very similiar results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's interesting, however; is in other portions of my code I am able to correctly access&amp;nbsp;an array of&amp;nbsp;structures defined on the S12X side with the XGATE (by using the #pragma align on/off).&amp;nbsp; The only difference is that the structures I am able to share do NOT contain pointers.&amp;nbsp; As such, I began this approach as a slick way to allow for pointers in these structures.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll take another&amp;nbsp;STAB at my proposed solution (I couldn't resist the HC11/12 humor), but now assuming the correct pointer size.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have any other thoughts, please let me know.&amp;nbsp; I will also update this thread with what happens.&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Dave&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Dave Subert on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-05-08&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;01:22 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2009 07:14:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178501#M6388</guid>
      <dc:creator>DaveSubert</dc:creator>
      <dc:date>2009-05-08T07:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help Sharing Pointers Between XGATE and S12X</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178502#M6389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;THANK&amp;nbsp;YOU!&amp;nbsp; THANK YOU!&amp;nbsp; THANK YOU!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Works great for&amp;nbsp;2 array entries.&amp;nbsp; Will be adding more and will follow up if any more problems/lessons encountered.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There were two problems:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; Cosmic represents far pointers in 4 bytes instead of 3 so my structure had to be re-defined taking this into account.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; This problem was a mistake on my part.&amp;nbsp; I changed include directories without updating the path in my makefile.&amp;nbsp; As a result, the XGATE code was not recognising the alternate definition of pulseo_chan_map.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hints that lead me to this conclusion:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; Pointer representation is defined by the compiler and can vary independent of hardware.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Never thought of using the sizeof() C function.&amp;nbsp; I instead created&amp;nbsp;listing files for everthing which was not as an efficient test.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks So Much for&amp;nbsp;Your Help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a part-time EE graduate student roughly 5 days days from the end of my semester.&amp;nbsp; I had already spent roughly a week on this problem.&amp;nbsp; Due to the time involved, I couldn't afford to loose more time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2009 09:46:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178502#M6389</guid>
      <dc:creator>DaveSubert</dc:creator>
      <dc:date>2009-05-08T09:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help Sharing Pointers Between XGATE and S12X</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178503#M6390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Success!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to say thanks again and provide an update on the results of my project.&amp;nbsp; Through the use of the XGATE I was able to effectively double the capabilty of the ECU I am designing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without the XGATE in a simulated application environment the CPU was 70% utilized and 30% free.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By using the XGATE, the CPU is now 30% utilized and 70% FREE!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To say the least, this is a very sobering result.&amp;nbsp; The XGATE is not a toy or product of marketing.&amp;nbsp; It is an extremely useful tool when applied correctly.&amp;nbsp; Interestingly enough, the development investment was not all that significant.&amp;nbsp; These results were achieved through a solid 3 months worth of research.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 May 2009 08:25:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Need-Help-Sharing-Pointers-Between-XGATE-and-S12X/m-p/178503#M6390</guid>
      <dc:creator>DaveSubert</dc:creator>
      <dc:date>2009-05-17T08:25:06Z</dc:date>
    </item>
  </channel>
</rss>

