<?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: How to allocate a banked (__far) function address to uint32_t? in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-allocate-a-banked-far-function-address-to-uint32-t/m-p/435742#M6916</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Snaku,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ever made sample code of far pointer to banked data address. see attached.&lt;/P&gt;&lt;P&gt;i think the method is similar for pointer to banked code address.&lt;/P&gt;&lt;P&gt;can this help?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Zhang Jun&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Apr 2015 06:54:30 GMT</pubDate>
    <dc:creator>ZhangJennie</dc:creator>
    <dc:date>2015-04-30T06:54:30Z</dc:date>
    <item>
      <title>How to allocate a banked (__far) function address to uint32_t?</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-allocate-a-banked-far-function-address-to-uint32-t/m-p/435741#M6915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am developing a boot-loader on MC9S12XE family with Classic CodeWarrior, I want to add a descriptor for the application code, and it should contain an address which is application code '&lt;SPAN style="font-family: 'courier new', courier;"&gt;_EntryPoint&lt;/SPAN&gt;' (i.e. the address store in application's reset vector), my problem is how to allocate the '&lt;SPAN style="font-family: 'courier new', courier;"&gt;_EntryPoint&lt;/SPAN&gt;' banked address to a uint32_t integer?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is an example of my problem, if I use the type '&lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333330154419px;"&gt;tIsrFunc&lt;/SPAN&gt;' to allocate &lt;SPAN style="font-size: 13.3333330154419px;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px; font-family: 'courier new', courier;"&gt;_EntryPoint&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;'&lt;/SPAN&gt; is OK but 16 bit value, e.g. 0x1234U.&lt;/P&gt;&lt;P&gt;If I cast &lt;SPAN style="font-size: 13.3333330154419px;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px; font-family: 'courier new', courier;"&gt;_EntryPoint&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;' to a uint32_t, the value will be shift left four bits, e.g. 0x00123400UL.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;How do I cast a backed function address to uint32_t without shifted left four bits?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;typedef void (*near tIsrFunc)(void);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;typedef struct APP_TRY_ADDR_S&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; tIsrFunc fptr_near;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; uint32_t fptr_far;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;}APP_TRY_ADDR_T;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;const APP_TRY_ADDR_T m_TryAddr =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; &amp;amp;_EntryPoint,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* it is OK, but 16 bit only */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; (uint32_t)&amp;amp;_EntryPoint,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* it is wrong, the value shifted left four bits */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2015 04:06:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-allocate-a-banked-far-function-address-to-uint32-t/m-p/435741#M6915</guid>
      <dc:creator>Snaku</dc:creator>
      <dc:date>2015-04-23T04:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to allocate a banked (__far) function address to uint32_t?</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-allocate-a-banked-far-function-address-to-uint32-t/m-p/435742#M6916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Snaku,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ever made sample code of far pointer to banked data address. see attached.&lt;/P&gt;&lt;P&gt;i think the method is similar for pointer to banked code address.&lt;/P&gt;&lt;P&gt;can this help?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Zhang Jun&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 06:54:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-allocate-a-banked-far-function-address-to-uint32-t/m-p/435742#M6916</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2015-04-30T06:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Re: How to allocate a banked (__far) function address to uint32_t?</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-allocate-a-banked-far-function-address-to-uint32-t/m-p/435743#M6917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Zhang Jun,&lt;/P&gt;&lt;P&gt;Sorry for my late reply, I try to change my example code with (unsign long * far) casting, but the result still shifted left four bits, 24 bits only, below is my test code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#pragma NO_FRAME&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#pragma NO_EXIT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;void _EntryPoint(void)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#pragma CODE_SEG DEFAULT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;typedef struct APP_TRY_ADDR_S&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; tIsrFunc fptr_near;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; unsigned long * __far fptr_far;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;}APP_TRY_ADDR_T;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;const APP_TRY_ADDR_T m_app_try_addr&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; &amp;amp;_EntryPoint,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* result is 0x4046 */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; (unsigned long * __far)&amp;amp;_EntryPoint,&amp;nbsp;&amp;nbsp; /* result is 0x404600, not 0x00004046 */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should I use logical paged address like &lt;A _jive_internal="true" href="https://community.nxp.com/message/57467#57467"&gt;this page&lt;/A&gt;? Then I can jump/call to application start address easier.&lt;/P&gt;&lt;P&gt;And I don't want to use &lt;SPAN style="font-size: 8pt; font-family: 'courier new', courier;"&gt;CONV_FAR_FUN_TO_DATA_PTR&lt;/SPAN&gt; or &lt;SPAN style="font-size: 8pt; font-family: 'courier new', courier;"&gt;CONV_FAR_DATA_TO_FUN_PTR&lt;/SPAN&gt; macro which introduced in "S12(X) Build Tools Reference Manual".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your support,&lt;/P&gt;&lt;P&gt;Snaku&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 06:30:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-allocate-a-banked-far-function-address-to-uint32-t/m-p/435743#M6917</guid>
      <dc:creator>Snaku</dc:creator>
      <dc:date>2015-05-04T06:30:10Z</dc:date>
    </item>
  </channel>
</rss>

