<?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: Running from stack, using TN235 that will not compile in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136957#M1920</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I would start by checking why you do get this C3802&lt;BR /&gt;message. My guess, the NEAR you are using is defined by a macro to __near.&lt;BR /&gt;Check how your pragma looks after preprocessing, there is a context menu entry to do this.&lt;BR /&gt;If this is the problem, try this:&lt;BR /&gt;&lt;BR /&gt;#pragma CODE_SEG __NEAR_SEG __PIC_SEG ToCopyToStack&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;(if ToCopyToStack needs to be non banked depends on how you copy it to the stack. I hope you stack is non banked tough :smileyhappy:&lt;BR /&gt;And calling other functions in flash should work as long as the accessed flash is accessible. However why do you execute the code out of RAM if you have flash which stays accessible?&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Nov 2006 23:03:24 GMT</pubDate>
    <dc:creator>CompilerGuru</dc:creator>
    <dc:date>2006-11-17T23:03:24Z</dc:date>
    <item>
      <title>Running from stack, using TN235 that will not compile</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136954#M1917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;CW 3.1 HCS12&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I need to run code from stack to erase and program flash.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have implemented TN235, thinking it will allow me to write programs in C,&lt;/DIV&gt;&lt;DIV&gt;put the code on the stack and execute from there. Although not absolutely&lt;/DIV&gt;&lt;DIV&gt;necessary, I would prefer to be able to call functions also located in banked memory.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;TN235 seems to resolve all this... BUT,&amp;nbsp;the compiler&amp;nbsp;complains about:&lt;/DIV&gt;&lt;DIV&gt;#pragma CODE_SEG NEAR PIC ToCopyToStack /* near and position independent */&lt;/DIV&gt;&lt;DIV&gt;issuing&amp;nbsp;warning C3802: Segment pragma incorrect&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;All help much appreciated&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Anders J&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Nov 2006 19:08:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136954#M1917</guid>
      <dc:creator>AndersJ</dc:creator>
      <dc:date>2006-11-16T19:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Running from stack, using TN235 that will not compile</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136955#M1918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;The restrictions section at the bottom of TN235 states:&lt;BR /&gt;&lt;BR /&gt;"The code copied to stack needs to be position independent and therefore must not contain runtime calls."&lt;BR /&gt;&lt;BR /&gt;Put another way, the PIC code is PC relative, using 16 bit addressing. If you're trying to access a function in another memory bank, you not using PIC code. To prove this, try commenting out your calls to functions in banked memory and see if the code compiles and links without errors.&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Nov 2006 23:34:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136955#M1918</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2006-11-16T23:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Running from stack, using TN235 that will not compile</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136956#M1919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Does this also mean that the code that copies the function to stack,&lt;/DIV&gt;&lt;DIV&gt;and then also "jumps to the stack" to execute it, must be in NON-banked memory?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Anders&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Nov 2006 00:38:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136956#M1919</guid>
      <dc:creator>AndersJ</dc:creator>
      <dc:date>2006-11-17T00:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Running from stack, using TN235 that will not compile</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136957#M1920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I would start by checking why you do get this C3802&lt;BR /&gt;message. My guess, the NEAR you are using is defined by a macro to __near.&lt;BR /&gt;Check how your pragma looks after preprocessing, there is a context menu entry to do this.&lt;BR /&gt;If this is the problem, try this:&lt;BR /&gt;&lt;BR /&gt;#pragma CODE_SEG __NEAR_SEG __PIC_SEG ToCopyToStack&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;(if ToCopyToStack needs to be non banked depends on how you copy it to the stack. I hope you stack is non banked tough :smileyhappy:&lt;BR /&gt;And calling other functions in flash should work as long as the accessed flash is accessible. However why do you execute the code out of RAM if you have flash which stays accessible?&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Nov 2006 23:03:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136957#M1920</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-11-17T23:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Running from stack, using TN235 that will not compile</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136958#M1921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Daniel,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Your pragma suggestions removed the warnings.&lt;/DIV&gt;&lt;DIV&gt;Thank you. This was a great help, moving me forward.&lt;/DIV&gt;&lt;DIV&gt;Strange that TN235 does not mention this issue.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I do not understand how to "Check how your pragma looks..."&lt;/DIV&gt;&lt;DIV&gt;Can you please explain this in some more detail, as I cannot find the "context menu".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My stack is not banked and after your help I am now able to execute from RAM.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I need to execute out of RAM, because I am reprogramming the flash with a new program.&lt;/DIV&gt;&lt;DIV&gt;In order to do that I need to erase the flash that is running the current program,&lt;/DIV&gt;&lt;DIV&gt;including non-banked flash, so I can put&amp;nbsp;my new program in those banks.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I cannot erase memory that I am executing from, so I need to move som programming&lt;/DIV&gt;&lt;DIV&gt;functions onto the stack and run it from there, now being able to erase and reprogram.&lt;/DIV&gt;&lt;DIV&gt;After all is said and done, I'll let the COP reset, and I'm up and running the new program.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is my plan. I'm not there yet.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks for your help,&lt;/DIV&gt;&lt;DIV&gt;Anders J&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;&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Nov 2006 01:07:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136958#M1921</guid>
      <dc:creator>AndersJ</dc:creator>
      <dc:date>2006-11-18T01:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Running from stack, using TN235 that will not compile</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136959#M1922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Have you tried looking at the application note AN2548.pdf, which describes a serial bootloader that can download to Flash? Perhaps that might be of help.&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;P&gt;Message Edited by J2MEJediMaster on &lt;SPAN class="date_text"&gt;2006-11-20&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:39 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/files/microcontrollers/doc/app_note/AN2548.pdf" rel="nofollow" target="_self"&gt;AN2548.pdf&lt;/A&gt;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by t.dowe on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-09-16&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;10:40 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2006 00:37:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Running-from-stack-using-TN235-that-will-not-compile/m-p/136959#M1922</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2006-11-21T00:37:57Z</dc:date>
    </item>
  </channel>
</rss>

