<?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 Function returns illogical value at runtime, but returns correct value during debug. in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Function-returns-illogical-value-at-runtime-but-returns-correct/m-p/159070#M9420</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;I'm running an application in the HCS08DZ60A microprocessor written in C.&amp;nbsp; I have a function that crunches a 5th-order polynomial and returns the result.&amp;nbsp; All variable types are 'float'.&amp;nbsp; Here are the bug symptoms:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)&amp;nbsp;The poly function returns an incorrect value when executing real-time in the platform.&amp;nbsp; However, if I step through the function using CodeWarrior Real-Time Debugger through the BDM port, the function returns the correct value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) The format of the function is:&amp;nbsp; float F_polyf(unsigned char n,&amp;nbsp;float *Coef,&amp;nbsp;float x) where x is the input value, *Coef is a pointer to an array of the coefficients, and n is the number of coefficients.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) I've been using this same poly function for 5 years in both the HC08AZ60A and HCS08DZ60A and it has always worked.&amp;nbsp; Now this time around, my application simply involved a 'minor' update to a seemingly unrelated area&amp;nbsp;and after&amp;nbsp;recompile the bug has appeared.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4) The bug only appears after a hardware power-up / reset.&amp;nbsp; If I exercise the product a bit after power-up, the bug clears up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5) I've verified my 'logic' with the CodeWarrior Real-Time Debugger. When stepping through the function with the debugger, the math comes out correctly.&amp;nbsp; Thus, my issue&amp;nbsp;seems related&amp;nbsp;to something&amp;nbsp;else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;6) I call this function in four different locations in my program, but the 'bug' only appears at one of the locations.&amp;nbsp; The other three locations always calculate correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone seen any symptoms like these?&amp;nbsp; I've run out of ideas, and I'm just looking for somewhere to go.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks much,&lt;/P&gt;&lt;P&gt;~Bizkits&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Oct 2010 22:40:00 GMT</pubDate>
    <dc:creator>belskyc</dc:creator>
    <dc:date>2010-10-29T22:40:00Z</dc:date>
    <item>
      <title>Function returns illogical value at runtime, but returns correct value during debug.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Function-returns-illogical-value-at-runtime-but-returns-correct/m-p/159070#M9420</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;I'm running an application in the HCS08DZ60A microprocessor written in C.&amp;nbsp; I have a function that crunches a 5th-order polynomial and returns the result.&amp;nbsp; All variable types are 'float'.&amp;nbsp; Here are the bug symptoms:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)&amp;nbsp;The poly function returns an incorrect value when executing real-time in the platform.&amp;nbsp; However, if I step through the function using CodeWarrior Real-Time Debugger through the BDM port, the function returns the correct value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) The format of the function is:&amp;nbsp; float F_polyf(unsigned char n,&amp;nbsp;float *Coef,&amp;nbsp;float x) where x is the input value, *Coef is a pointer to an array of the coefficients, and n is the number of coefficients.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) I've been using this same poly function for 5 years in both the HC08AZ60A and HCS08DZ60A and it has always worked.&amp;nbsp; Now this time around, my application simply involved a 'minor' update to a seemingly unrelated area&amp;nbsp;and after&amp;nbsp;recompile the bug has appeared.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4) The bug only appears after a hardware power-up / reset.&amp;nbsp; If I exercise the product a bit after power-up, the bug clears up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5) I've verified my 'logic' with the CodeWarrior Real-Time Debugger. When stepping through the function with the debugger, the math comes out correctly.&amp;nbsp; Thus, my issue&amp;nbsp;seems related&amp;nbsp;to something&amp;nbsp;else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;6) I call this function in four different locations in my program, but the 'bug' only appears at one of the locations.&amp;nbsp; The other three locations always calculate correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone seen any symptoms like these?&amp;nbsp; I've run out of ideas, and I'm just looking for somewhere to go.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks much,&lt;/P&gt;&lt;P&gt;~Bizkits&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Oct 2010 22:40:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Function-returns-illogical-value-at-runtime-but-returns-correct/m-p/159070#M9420</guid>
      <dc:creator>belskyc</dc:creator>
      <dc:date>2010-10-29T22:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Function returns illogical value at runtime, but returns correct value during debug.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Function-returns-illogical-value-at-runtime-but-returns-correct/m-p/159071#M9421</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;This could be indicative of a stack overflow problem - the changes that you did may have increased the stack size requirement, and global or static variables could be over-written.&amp;nbsp; Does the function make use of any of these?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The fact that the problem only occurs at one of the four locations where the function is called, may be determined by the stack usage prior to the call.&amp;nbsp; Also perhaps all interrupts do not occur when you are single stepping - each interrypt will require additional stack on top of that required for the floating point operations.&amp;nbsp; I assume that you are not attempting to use nested interrupts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is the array of coefficients meant to be constant data, to be located in flash?&amp;nbsp; Perhaps the data actually resides in RAM.&amp;nbsp; The project map file should reveal its location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Oct 2010 23:13:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Function-returns-illogical-value-at-runtime-but-returns-correct/m-p/159071#M9421</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2010-10-29T23:13:00Z</dc:date>
    </item>
  </channel>
</rss>

