<?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 S12X CW4.5 function pointers in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135587#M1735</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;S12XDP512, CW 4.5, LARGE memory model&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have a function pointer defined as&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;typedef void (*function)(void);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have a void pointer which is holding the function address&amp;nbsp; 0x7DB089'G ( which is actually laid out in memory as B0897D.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;When I attempt to cast it (or call it) the runtime GLOBAL_TO_LOCAL function is called. The result&amp;nbsp;is&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;0x7DC289 (or&amp;nbsp;&amp;nbsp;C2897D as laid out in memory). This is incorrect and crashes the code.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any suggestions how I can get around this. I'm guessing that the routine assumes this is a data pointer and not a function pointer?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Cheers&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 May 2006 09:35:41 GMT</pubDate>
    <dc:creator>gravity</dc:creator>
    <dc:date>2006-05-11T09:35:41Z</dc:date>
    <item>
      <title>S12X CW4.5 function pointers</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135587#M1735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;S12XDP512, CW 4.5, LARGE memory model&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have a function pointer defined as&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;typedef void (*function)(void);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have a void pointer which is holding the function address&amp;nbsp; 0x7DB089'G ( which is actually laid out in memory as B0897D.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;When I attempt to cast it (or call it) the runtime GLOBAL_TO_LOCAL function is called. The result&amp;nbsp;is&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;0x7DC289 (or&amp;nbsp;&amp;nbsp;C2897D as laid out in memory). This is incorrect and crashes the code.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any suggestions how I can get around this. I'm guessing that the routine assumes this is a data pointer and not a function pointer?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Cheers&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 May 2006 09:35:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135587#M1735</guid>
      <dc:creator>gravity</dc:creator>
      <dc:date>2006-05-11T09:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: S12X CW4.5 function pointers</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135588#M1736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi Gravity,&lt;/P&gt;&lt;P&gt;When you use external address space, you need to use FAR pointers to indicate to the debugger which space you address and avoid address to be truncated or wrong.&lt;/P&gt;&lt;P&gt;&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&amp;amp;message.id=238&amp;amp;query.id=685#M238" target="_blank"&gt;See&amp;nbsp;Nabla's post and the code I had on the NE64 with extended bus&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;If I understood well what you meant...&lt;BR /&gt;Alban.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 May 2006 17:26:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135588#M1736</guid>
      <dc:creator>Alban</dc:creator>
      <dc:date>2006-05-11T17:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: S12X CW4.5 function pointers</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135589#M1737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;I compiling using large memory model, so I thought everything is a far pointer?&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 May 2006 09:02:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135589#M1737</guid>
      <dc:creator>gravity</dc:creator>
      <dc:date>2006-05-12T09:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: S12X CW4.5 function pointers</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135590#M1738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Sorry, but I can't confirm...&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 May 2006 14:43:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135590#M1738</guid>
      <dc:creator>Alban</dc:creator>
      <dc:date>2006-05-12T14:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: S12X CW4.5 function pointers</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135591#M1739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I think my problem is S12X specific and is to do with translating from a Global address to a local address.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;The global address is 0x7DB089'G&amp;nbsp;but the local address becomes 0xF6C289'L&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 May 2006 08:39:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135591#M1739</guid>
      <dc:creator>gravity</dc:creator>
      <dc:date>2006-05-13T08:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: S12X CW4.5 function pointers</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135592#M1740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;Which CPU are you currently using (HCS12XDP512, ....)?&lt;/P&gt;&lt;P&gt;From what I can see (from HCS12X reference manual), address 0x7DB089'G is in fact equivalent to address 0xF6B089'L.&lt;/P&gt;&lt;P&gt;All absolute addresses you specify in ANSI C source code are considered as logical (even in large memory model).&lt;/P&gt;&lt;P&gt;So instead of writing&lt;/P&gt;&lt;P&gt;&amp;nbsp;typedef void (*function)(void);&lt;BR /&gt;&amp;nbsp;function func;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;func = (function) 0x7DB089;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;func();&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;You have to write&lt;/P&gt;&lt;P&gt;&amp;nbsp;typedef void (*function)(void);&lt;BR /&gt;&amp;nbsp;function func;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;func = (function) 0xF6B089;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;func();&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 May 2006 17:57:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135592#M1740</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-05-15T17:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: S12X CW4.5 function pointers</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135593#M1741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;S12XDP512.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The problem was that I was passing the function pointer around using a "void*". I had made this "void*" a "void* far", so it was casting it to global addressing.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Cheers&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;M&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 May 2006 05:26:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135593#M1741</guid>
      <dc:creator>gravity</dc:creator>
      <dc:date>2006-05-16T05:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: S12X CW4.5 function pointers</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135594#M1742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;Is the problem fixed now?&lt;BR /&gt;&amp;nbsp;If not, can you send me a code snippet reproducing the trouble.&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 May 2006 15:30:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/S12X-CW4-5-function-pointers/m-p/135594#M1742</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-05-16T15:30:05Z</dc:date>
    </item>
  </channel>
</rss>

