<?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: MCF52259 and CW 7.1.1 pro (eval) returning value problem in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195534#M8658</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here in your example&amp;nbsp;you have a common C language misunderstanding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can not return a pointer which points to a local variable!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'poutine' is out of scope when you return from the routine. so 'q' is points&amp;nbsp;an in-valid location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you allocate 'poutine' as global variable, it should work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When it is defined locally, you can treat that the variable is allocated in stack. when returns, the stack is cleard, p is points to invalid location ( that memory or stack reallocated by others....&amp;nbsp;).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you use p= new() or p= alloc() to allocate memory (from the heap )&amp;nbsp;in the module, unless you use delete() or free() to release the memory, the memory is always valid...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by eGuy on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-01&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;02:02 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Jul 2009 00:44:30 GMT</pubDate>
    <dc:creator>eGuy</dc:creator>
    <dc:date>2009-07-02T00:44:30Z</dc:date>
    <item>
      <title>MCF52259 and CW 7.1.1 pro (eval) returning value problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195527#M8651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a function that is supposed to return a pointer to a structure in the RAM, let's say it should return 0x200063FC.&amp;nbsp; The problem I got with this function is that its always returning 0x1 and it causes the rest of my program to crash.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know the function code itself is not the cause.&amp;nbsp; I've used it already with no problem.&amp;nbsp; (its pbuf_alloc() from lwip 1.3.0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe the target (internal FLASH) isnt set properly or some init code hasnt been called.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FB&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2009 04:46:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195527#M8651</guid>
      <dc:creator>francois_boucha</dc:creator>
      <dc:date>2009-07-01T04:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and CW 7.1.1 pro (eval) returning value problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195528#M8652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you using some kind of RTOS with lwIP? CHeck if stack space is enough for task calling pbuf_alloc. Weird things happen when stack overflow selected space. Do not forget interrupts used with your project must be considered on each task's stack as well if RTOS is not using user/supervisor space to have a dedicated interrupt stack.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also try to debug function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2009 12:34:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195528#M8652</guid>
      <dc:creator>PaoloRenzo</dc:creator>
      <dc:date>2009-07-01T12:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and CW 7.1.1 pro (eval) returning value problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195529#M8653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are the two routines compiled with the same settings (eg. is one being taken from a library compiled differently?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that there is a #pragma pointers_in_A0 (in mwerks.h) which defines how the project code is compiled. With this pragma set, routines which return addresses do so via the register a0 and data values are returned via d0. Without the pragma set both address and data values are returned via d0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have, for example, this set when compiling a project but the library used was compiled without it you will find that the library returns an address in d0 but you application code will take the return value from a0 - which will be essentially undefined (but possibly always the same). A mismatch the otherway around will also cause returned addresses to be incorrect. Returned data values will however always match.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just an idea...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.uTasker.com" rel="nofollow" target="_blank"&gt;www.uTasker.com&lt;/A&gt;&lt;BR /&gt;- OS, TCP/IP stack, USB, device drivers and simulator for M521X, M521XX, M5221X, M5222X, M5223X, M5225X. One package does them all - "&lt;EM&gt;Embedding it better...&lt;/EM&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2009 18:45:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195529#M8653</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2009-07-01T18:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and CW 7.1.1 pro (eval) returning value problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195530#M8654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Interesting, and now how could I set this pragma globally?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2009 23:11:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195530#M8654</guid>
      <dc:creator>francois_boucha</dc:creator>
      <dc:date>2009-07-01T23:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and CW 7.1.1 pro (eval) returning value problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195531#M8655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No I'm in standalone lwIP...&lt;/P&gt;&lt;P&gt;thx for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2009 23:12:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195531#M8655</guid>
      <dc:creator>francois_boucha</dc:creator>
      <dc:date>2009-07-01T23:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and CW 7.1.1 pro (eval) returning value problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195532#M8656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've just checked the register A0, and the return addresses seems to transit via register A0.&amp;nbsp; I saw the return address in that register, and it is the same as the one I see in the debbuger.&amp;nbsp; But p still affected with 0x1 after the call:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
p = pbuf_alloc( PBUF_RAW, pNBuf-&amp;gt;length, PBUF_POOL);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;FB&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:50:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195532#M8656</guid>
      <dc:creator>francois_boucha</dc:creator>
      <dc:date>2020-10-29T09:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and CW 7.1.1 pro (eval) returning value problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195533#M8657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;its funny, I've made a private function to test address returning value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
struct pbuf * ret_ptr(int a, int b, int c){ struct pbuf * q; struct pbuf poutine; poutine.len = 500; poutine.tot_len = 500; poutine.next = 0; poutine.type = 1; poutine.ref = 0;  ++c;  q = &amp;amp;poutine; return q;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; It work normally well when it is defined locally and called within the same module.&amp;nbsp; But if it is declared in another module it always returns 0x1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could it be a heap problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:50:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195533#M8657</guid>
      <dc:creator>francois_boucha</dc:creator>
      <dc:date>2020-10-29T09:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and CW 7.1.1 pro (eval) returning value problem</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195534#M8658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here in your example&amp;nbsp;you have a common C language misunderstanding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can not return a pointer which points to a local variable!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'poutine' is out of scope when you return from the routine. so 'q' is points&amp;nbsp;an in-valid location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you allocate 'poutine' as global variable, it should work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When it is defined locally, you can treat that the variable is allocated in stack. when returns, the stack is cleard, p is points to invalid location ( that memory or stack reallocated by others....&amp;nbsp;).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you use p= new() or p= alloc() to allocate memory (from the heap )&amp;nbsp;in the module, unless you use delete() or free() to release the memory, the memory is always valid...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by eGuy on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-01&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;02:02 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2009 00:44:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-CW-7-1-1-pro-eval-returning-value-problem/m-p/195534#M8658</guid>
      <dc:creator>eGuy</dc:creator>
      <dc:date>2009-07-02T00:44:30Z</dc:date>
    </item>
  </channel>
</rss>

