<?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 Re: Problem with __far function pointer in S12XEP100 in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196710#M7815</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes it is useful to read a documentation &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;. Thath right my function pointer points to data not function.&amp;nbsp; So I modify my code like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-&lt;BR /&gt;Byte&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; pseq_addproc&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (Byte *name, void * pointer)&amp;nbsp;&amp;nbsp;&amp;nbsp; // dodanie procedury do kolejki&lt;BR /&gt;{&lt;BR /&gt;void (*__far FunPtr)(void)= Tmr_SysLed;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...&lt;BR /&gt;pseq_pdatx[i].proc_pointer = FunPtr;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That works fine but I dont use input *pointer from function pseq_addproc but I openly write pointer to function Tmr_SysLed fo FunPtr and later to structure pseq_pdatx. I have no idea how write input pointer to structure instead od FunPtr like now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In line&amp;nbsp;&lt;/P&gt;&lt;P&gt;pseq_addproc((Byte*)"SysLed Timer", &amp;amp;Tmr_SysLed);&lt;/P&gt;&lt;P&gt;I have warning Pointer conversion: possible loss of data, so pointer is ony 16 bit wide ;/&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Earlier I have no problem here because of using large memory model and pointer was always 23 bit wide.&amp;nbsp; When I modify function&amp;nbsp; like that:&lt;/P&gt;&lt;P&gt;pseq_addproc&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (Byte *name, void *__far pointer),&lt;/P&gt;&lt;P&gt;pointer is 23 bit wide but points to bad address (page is wrong), for example:&lt;/P&gt;&lt;P&gt;Tmr_SysLed has address: a3d5FE&lt;/P&gt;&lt;P&gt;pointer points to: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; a3d57F&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by cs_Lukasz on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-07&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;10:50 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Jul 2009 16:24:17 GMT</pubDate>
    <dc:creator>cs_Lukasz</dc:creator>
    <dc:date>2009-07-07T16:24:17Z</dc:date>
    <item>
      <title>Problem with __far function pointer in S12XEP100</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196707#M7812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;In my project I use function pointers. Memory is banked. I dont use X-Gate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;typedef struct&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;...&lt;BR /&gt;&amp;nbsp; volatile&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Byte&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(*__far proc_pointer) (void);&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// pointer do wykonania procedury&lt;BR /&gt;...&lt;BR /&gt;} pseq_pdat;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Byte&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; pseq_addproc&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (Byte *name, void *__far pointer)&amp;nbsp;&amp;nbsp;&amp;nbsp; // dodanie procedury do kolejki&lt;BR /&gt;{&lt;BR /&gt;volatile&amp;nbsp;&amp;nbsp;&amp;nbsp; pseq_dat&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; *pseq_datx;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;volatile&amp;nbsp;&amp;nbsp;&amp;nbsp; pseq_pdat&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; *pseq_pdatx;&lt;BR /&gt;...&lt;BR /&gt;pseq_pdatx[i].proc_pointer = (Byte (* __far) (void))pointer;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;...&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In code I use a function for ex:&lt;/P&gt;&lt;P&gt;pseq_addproc((Byte*)"SysLed Timer", &amp;amp;Tmr_SysLed);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In map file function Tmr_SysLed has address 0xFEA3E6. But when I run debug mode I see the pointer has address: 0xFE2B07. There are no functions at this address, but there is struct pseq_datx. I dont now why pointer points to bad address ;/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regard&lt;/P&gt;&lt;P&gt;Lukasz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2009 19:42:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196707#M7812</guid>
      <dc:creator>cs_Lukasz</dc:creator>
      <dc:date>2009-07-06T19:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with __far function pointer in S12XEP100</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196708#M7813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;My code is small and is located only in PPAGE 0xFE so i'm not sure but propably i dont have to use far pointers. But when I executed function pointer pseq_pdatx[i].proc_pointer(); a PC jump to illegal address ;/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I forget earlier my code works well but on memory model large. When i'm usink memory model banked it dont work.&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by cs_Lukasz on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-06&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;02:25 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2009 20:17:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196708#M7813</guid>
      <dc:creator>cs_Lukasz</dc:creator>
      <dc:date>2009-07-06T20:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with __far function pointer in S12XEP100</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196709#M7814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if this is you issue, but in the code I see a conversion from a __far data to a __far function pointer.&lt;/P&gt;&lt;P&gt;Note that those types of pointers are not compatible, you can start with a __far function pointer, cast it to a __far void pointer and cast it back, that ok.&lt;/P&gt;&lt;P&gt;But you cannot direcly use a data pointer to access the code the function pointer points to.&lt;/P&gt;&lt;P&gt;(or use a function pointer to execute the code a data pointer points to).&lt;/P&gt;&lt;P&gt;The reason is that __far data and __far function pointers are using a different byte ordering, see the compiler manual for details. Basically __far data pointers are big endian encoded, __far function pointer use a format so they are in memory usable by the HC12 CALL instruction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I doubt a bit because the address you mention does not look like this is the issue you have. Just something which comes to mind when looking at __far function pointers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check if the function pseq_addproc is called with the right address or if the problem occurs in there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(and, BTW, for the S12X, __far data pointer are using global addresses too).&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2009 22:20:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196709#M7814</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2009-07-06T22:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with __far function pointer in S12XEP100</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196710#M7815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes it is useful to read a documentation &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;. Thath right my function pointer points to data not function.&amp;nbsp; So I modify my code like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-&lt;BR /&gt;Byte&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; pseq_addproc&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (Byte *name, void * pointer)&amp;nbsp;&amp;nbsp;&amp;nbsp; // dodanie procedury do kolejki&lt;BR /&gt;{&lt;BR /&gt;void (*__far FunPtr)(void)= Tmr_SysLed;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...&lt;BR /&gt;pseq_pdatx[i].proc_pointer = FunPtr;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That works fine but I dont use input *pointer from function pseq_addproc but I openly write pointer to function Tmr_SysLed fo FunPtr and later to structure pseq_pdatx. I have no idea how write input pointer to structure instead od FunPtr like now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In line&amp;nbsp;&lt;/P&gt;&lt;P&gt;pseq_addproc((Byte*)"SysLed Timer", &amp;amp;Tmr_SysLed);&lt;/P&gt;&lt;P&gt;I have warning Pointer conversion: possible loss of data, so pointer is ony 16 bit wide ;/&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Earlier I have no problem here because of using large memory model and pointer was always 23 bit wide.&amp;nbsp; When I modify function&amp;nbsp; like that:&lt;/P&gt;&lt;P&gt;pseq_addproc&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (Byte *name, void *__far pointer),&lt;/P&gt;&lt;P&gt;pointer is 23 bit wide but points to bad address (page is wrong), for example:&lt;/P&gt;&lt;P&gt;Tmr_SysLed has address: a3d5FE&lt;/P&gt;&lt;P&gt;pointer points to: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; a3d57F&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by cs_Lukasz on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-07&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;10:50 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2009 16:24:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196710#M7815</guid>
      <dc:creator>cs_Lukasz</dc:creator>
      <dc:date>2009-07-07T16:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with __far function pointer in S12XEP100</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196711#M7816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I find the solution:&lt;/P&gt;&lt;P&gt;- bad syntax:&lt;/P&gt;&lt;P&gt;pseq_addproc((Byte*)"SysLed Timer", &amp;amp;Tmr_SysLed);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- good syntax:&lt;/P&gt;&lt;P&gt;void (*__far FunPtr)(void)= Tmr_SysLed;&lt;BR /&gt;pseq_addproc((Byte*)"SysLed Timer", FunPtr);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2009 17:15:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-far-function-pointer-in-S12XEP100/m-p/196711#M7816</guid>
      <dc:creator>cs_Lukasz</dc:creator>
      <dc:date>2009-07-07T17:15:58Z</dc:date>
    </item>
  </channel>
</rss>

