<?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: Reentrant Functions in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227125#M9012</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks !&amp;nbsp; I must have an interrupt priority problem then.&amp;nbsp; So for clarification, If I have 3 interrupts each calling the same function at once, all of the local ( non static) variables in that function would be separate.&amp;nbsp; IE you would have 3 different copies of the variable and two of those copies would be automatically on the stack at any one point while in all 3.&amp;nbsp;&amp;nbsp; As always, Thank you guys for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Mar 2013 14:07:29 GMT</pubDate>
    <dc:creator>SecondTechCo</dc:creator>
    <dc:date>2013-03-15T14:07:29Z</dc:date>
    <item>
      <title>Reentrant Functions</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227120#M9007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have search a lot and cannot find virtually anything on reentrant functions in the documentation.&amp;nbsp; Eventually I came across this statement.&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: 'Times New Roman','serif'; font-size: 12pt;"&gt;When local variables are allocated at fixed addresses, the resulting code is not reentrant. Each &lt;SPAN style="background: #ffff66; color: black;"&gt;function&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; must be called only once. Take special care with interrupt &lt;SPAN style="background: #ffff66; color: black;"&gt;function&lt;/SPAN&gt;s: they must not call any &lt;SPAN style="background: #ffff66; color: black;"&gt;function&lt;/SPAN&gt; which might&lt;BR /&gt;&amp;nbsp; be active at the interrupt time. To be on the safe side, interrupt &lt;SPAN style="background: #ffff66; color: black;"&gt;function&lt;/SPAN&gt;s usually use a different set of &lt;SPAN style="background: #ffff66; color: black;"&gt;function&lt;/SPAN&gt;s&lt;BR /&gt;&amp;nbsp; than non-interrupt &lt;SPAN style="background: #ffff66; color: black;"&gt;function&lt;/SPAN&gt;s.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this the way all functions work in codewarrior c or is there a way to get codewarrior to support functions which put their local variables on the stack ( MCF51 and codewarrior 10+ but am not sure if this matters ) ??&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Some languages have the keyword reentrant for this.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there isnt another way, is the only way do this to add flag to the code to prevent entry into a function while another part of the code is using the function ?&amp;nbsp; This sounds messy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 12:56:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227120#M9007</guid>
      <dc:creator>SecondTechCo</dc:creator>
      <dc:date>2013-03-15T12:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Reentrant Functions</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227121#M9008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;'local variables allocated at fixed addresses' refers here to 'static locals', like&lt;/P&gt;&lt;P&gt;void foo(void) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; static int local; /* static local variable, local scope, but is a normal 'static' variable with a fixed memory address */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in above case, the local variable is not on the stack, but it treated like any static variable (static or external).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what the documentation says is just what is normal in the C language.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And you do not need to use any special keyword/etc: CodeWarrior will allocate 'true' local variables on the stack, as everybody would expect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 13:02:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227121#M9008</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2013-03-15T13:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Reentrant Functions</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227122#M9009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if i have this function:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;void foo(void) {&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; int localvar;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;and i am running it from my main and I call it from an interrupt, the variable localvar gets overwritten.&amp;nbsp; Doesn't the same thing happen if I declare it static ?&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 13:09:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227122#M9009</guid>
      <dc:creator>SecondTechCo</dc:creator>
      <dc:date>2013-03-15T13:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Reentrant Functions</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227123#M9010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IE while I am in the middle of the function and interrupt calls the same function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 13:10:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227123#M9010</guid>
      <dc:creator>SecondTechCo</dc:creator>
      <dc:date>2013-03-15T13:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reentrant Functions</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227124#M9011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you declare it static, then it will basically a global variable, there will be only one copy of it and the function will NOT be re-entrant. The way you it show it now is correct.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 13:27:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227124#M9011</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2013-03-15T13:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reentrant Functions</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227125#M9012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks !&amp;nbsp; I must have an interrupt priority problem then.&amp;nbsp; So for clarification, If I have 3 interrupts each calling the same function at once, all of the local ( non static) variables in that function would be separate.&amp;nbsp; IE you would have 3 different copies of the variable and two of those copies would be automatically on the stack at any one point while in all 3.&amp;nbsp;&amp;nbsp; As always, Thank you guys for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 14:07:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227125#M9012</guid>
      <dc:creator>SecondTechCo</dc:creator>
      <dc:date>2013-03-15T14:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reentrant Functions</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227126#M9013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. Well, all 3 would be on the stack, but at different locations on the stack.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 14:34:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reentrant-Functions/m-p/227126#M9013</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2013-03-15T14:34:59Z</dc:date>
    </item>
  </channel>
</rss>

