<?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>Classic/Legacy CodeWarrior中的主题 Function Return and Variable Disappear</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Function-Return-and-Variable-Disappear/m-p/216911#M6223</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;i got a problem getting me crazy &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i got a function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;float FUNCTIONS_convolution(uint16_t x[], uint16_t y[]){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t i = 0;&amp;nbsp; float x_bar = 0.00;&amp;nbsp; float y_bar = 0.00;&amp;nbsp; float sigma_x = 0.0;&amp;nbsp; float sigma_y = 0.0;&amp;nbsp; float sigma_xy = 0.0;&amp;nbsp; float rho = 0.0;&amp;nbsp; ...&amp;nbsp; some crazy calculations &lt;SPAN aria-label="Wink" class="emoticon-inline emoticon_wink" style="height:16px;width:16px;"&gt;&lt;/SPAN&gt;&amp;nbsp; ...&amp;nbsp; sigma_xy = (sigma_xy / 9.0);&amp;nbsp; rho = (sigma_xy / (sigma_x * sigma_y));&amp;nbsp;&amp;nbsp;&amp;nbsp; return rho;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i call it from my main function with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* Write your local variable definition here */&amp;nbsp; uint16_t x[10] = {1,2,3,4,5,6,7,8,9,10};&amp;nbsp; uint16_t y[10] = {1,2,3,4,5,6,7,8,9,10};&amp;nbsp; float convolution = 0.0;&amp;nbsp; float temp = 0.0;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/&amp;nbsp; PE_low_level_init();&amp;nbsp; /*** End of Processor Expert internal initialization.&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; /* Write your code here */&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&amp;nbsp; some initialisation stuff&amp;nbsp; ...&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(process == CONVOLUTION)&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; convolution = FUNCTIONS_convolution(x, y);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp = 2*convolution;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(temp &amp;lt;= convolution)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FUNCTIONS_usb_send_byte('O');&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; process = IDLE;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now my problem is that in my function the calculations are done up to the last few lines...&lt;/P&gt;&lt;P&gt;sigma_xy has a value, but it keeps it value even after division.&lt;/P&gt;&lt;P&gt;after that rho is not calculated and stepping in the tru time simulator skips the calculation and return value.&lt;/P&gt;&lt;P&gt;in the simulator (P&amp;amp;E Debugger, software running on hardware) the variables rho, convolution and temp are not shown.&lt;/P&gt;&lt;P&gt;the if case is not correct, its just a tryout to tell the compiler that i need that variables &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;whats wrong and how can i tell the compiler not to cut my variables away &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im using codewarrior 4.7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Compiler throws a warning: C12056: SP debug info incorrect because of optimization or inline assembler&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im not using inline assembler, maybe from the includet math.h?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Aug 2010 20:55:14 GMT</pubDate>
    <dc:creator>HarryHirn</dc:creator>
    <dc:date>2010-08-05T20:55:14Z</dc:date>
    <item>
      <title>Function Return and Variable Disappear</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Function-Return-and-Variable-Disappear/m-p/216911#M6223</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;i got a problem getting me crazy &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i got a function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;float FUNCTIONS_convolution(uint16_t x[], uint16_t y[]){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t i = 0;&amp;nbsp; float x_bar = 0.00;&amp;nbsp; float y_bar = 0.00;&amp;nbsp; float sigma_x = 0.0;&amp;nbsp; float sigma_y = 0.0;&amp;nbsp; float sigma_xy = 0.0;&amp;nbsp; float rho = 0.0;&amp;nbsp; ...&amp;nbsp; some crazy calculations &lt;SPAN aria-label="Wink" class="emoticon-inline emoticon_wink" style="height:16px;width:16px;"&gt;&lt;/SPAN&gt;&amp;nbsp; ...&amp;nbsp; sigma_xy = (sigma_xy / 9.0);&amp;nbsp; rho = (sigma_xy / (sigma_x * sigma_y));&amp;nbsp;&amp;nbsp;&amp;nbsp; return rho;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i call it from my main function with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* Write your local variable definition here */&amp;nbsp; uint16_t x[10] = {1,2,3,4,5,6,7,8,9,10};&amp;nbsp; uint16_t y[10] = {1,2,3,4,5,6,7,8,9,10};&amp;nbsp; float convolution = 0.0;&amp;nbsp; float temp = 0.0;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/&amp;nbsp; PE_low_level_init();&amp;nbsp; /*** End of Processor Expert internal initialization.&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; /* Write your code here */&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&amp;nbsp; some initialisation stuff&amp;nbsp; ...&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(process == CONVOLUTION)&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; convolution = FUNCTIONS_convolution(x, y);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp = 2*convolution;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(temp &amp;lt;= convolution)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FUNCTIONS_usb_send_byte('O');&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; process = IDLE;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now my problem is that in my function the calculations are done up to the last few lines...&lt;/P&gt;&lt;P&gt;sigma_xy has a value, but it keeps it value even after division.&lt;/P&gt;&lt;P&gt;after that rho is not calculated and stepping in the tru time simulator skips the calculation and return value.&lt;/P&gt;&lt;P&gt;in the simulator (P&amp;amp;E Debugger, software running on hardware) the variables rho, convolution and temp are not shown.&lt;/P&gt;&lt;P&gt;the if case is not correct, its just a tryout to tell the compiler that i need that variables &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;whats wrong and how can i tell the compiler not to cut my variables away &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im using codewarrior 4.7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Compiler throws a warning: C12056: SP debug info incorrect because of optimization or inline assembler&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im not using inline assembler, maybe from the includet math.h?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Aug 2010 20:55:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Function-Return-and-Variable-Disappear/m-p/216911#M6223</guid>
      <dc:creator>HarryHirn</dc:creator>
      <dc:date>2010-08-05T20:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Function Return and Variable Disappear</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Function-Return-and-Variable-Disappear/m-p/216912#M6224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i think i posted in the wrong subforum, maybe someone could move me to the codewarrior topic... &lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Aug 2010 19:19:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Function-Return-and-Variable-Disappear/m-p/216912#M6224</guid>
      <dc:creator>HarryHirn</dc:creator>
      <dc:date>2010-08-06T19:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Function Return and Variable Disappear</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Function-Return-and-Variable-Disappear/m-p/216913#M6225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the SP debug warning comes from the IDE. For each C file in your project you need to click the little green bug in the project browser, to enable debug info.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that didn't solve the problem, it sounds like an optimization issue. When debugging, declare variables as volatile to prevent optimization.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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>Mon, 09 Aug 2010 20:12:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Function-Return-and-Variable-Disappear/m-p/216913#M6225</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2010-08-09T20:12:40Z</dc:date>
    </item>
  </channel>
</rss>

