<?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>Digital Signal Controllers中的主题 Re: Why does this simple conditional misbehave on a MC56F8006?</title>
    <link>https://community.nxp.com/t5/Digital-Signal-Controllers/Why-does-this-simple-conditional-misbehave-on-a-MC56F8006/m-p/240300#M20</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Iance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried replicating the issue but could not succeed.&lt;/P&gt;&lt;P&gt;Can you share your code so that I can analyse it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards&lt;/P&gt;&lt;P&gt;Arpita Agarwal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 May 2014 08:02:00 GMT</pubDate>
    <dc:creator>arpitaagarwal-b</dc:creator>
    <dc:date>2014-05-21T08:02:00Z</dc:date>
    <item>
      <title>Why does this simple conditional misbehave on a MC56F8006?</title>
      <link>https://community.nxp.com/t5/Digital-Signal-Controllers/Why-does-this-simple-conditional-misbehave-on-a-MC56F8006/m-p/240299#M19</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following code in a Processor Expert project (CW 10.5) that get's executed once every 10ms:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #3366ff;"&gt; if (timer1 &amp;lt; 255) timer1++;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The timer1 variable is declared as an unsigned 8 bit integer (UInt8) initialized to zero and is set to zero under certain conditions and tested for being greater than some other value elsewhere E.G..&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #3366ff;"&gt;if (condition1) timer1 = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if (timer1 &amp;gt; value1) doSomethin();&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The intent is to execute "doSomethin" if condition1 is false for 10 * value1&amp;nbsp; consecutive milliseconds.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The behavior I'm seeing is that when timer1 reaches 255 is rolls over to zero.&amp;nbsp; I've tried changing the "255" limit to 250 but it still misbehaves the same way (always increments).&lt;/P&gt;&lt;P&gt;I did a project wide text search for the "timer1" variable which didn't turn up any other references to timer1.&amp;nbsp; I also changed the initialization and (conditional) reset value from 0 to 2 and confirmed that it still goes from 255 to 0 rather than staying at 255.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked at the disassembly&amp;nbsp; listing and find that it appears the compiler has generated the code correctly:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;moveu.bp X:0x000244,A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;cmp.b #255,A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;bcc Fmain+0x5a3 (0x1627)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;nop&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;nop&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;inc.bp X:0x000244&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;(0x1627)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did some instruction step debugging and found that if I break on the line after the last line of that assembly code and set timer1 to 254 then run to the breakpoint again, CPU register A is zero but RAM location 0x244 still contains 255.&amp;nbsp; The only way I can see that happening would be if an interrupt occurred right after the move from 0x255 and the interrupt routine cleared register A.&amp;nbsp; I did verify that all PE components that have interrupts enabled are configured with "Interrupt preserve registers" set to yes.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did find that I get the expected behavior&amp;nbsp; if I modified the code thusly:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt; if (timer1 &amp;lt; 255) timer1++;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;else timer1 = 255;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But that extra line shouldn't be necessary and I'm concerned about what else might be affected in a similar manner.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm at a loss WRT how to proceed from here.&amp;nbsp; Any help would be greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 21:50:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Digital-Signal-Controllers/Why-does-this-simple-conditional-misbehave-on-a-MC56F8006/m-p/240299#M19</guid>
      <dc:creator>lancefisher</dc:creator>
      <dc:date>2014-02-17T21:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this simple conditional misbehave on a MC56F8006?</title>
      <link>https://community.nxp.com/t5/Digital-Signal-Controllers/Why-does-this-simple-conditional-misbehave-on-a-MC56F8006/m-p/240300#M20</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Iance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried replicating the issue but could not succeed.&lt;/P&gt;&lt;P&gt;Can you share your code so that I can analyse it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards&lt;/P&gt;&lt;P&gt;Arpita Agarwal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2014 08:02:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Digital-Signal-Controllers/Why-does-this-simple-conditional-misbehave-on-a-MC56F8006/m-p/240300#M20</guid>
      <dc:creator>arpitaagarwal-b</dc:creator>
      <dc:date>2014-05-21T08:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this simple conditional misbehave on a MC56F8006?</title>
      <link>https://community.nxp.com/t5/Digital-Signal-Controllers/Why-does-this-simple-conditional-misbehave-on-a-MC56F8006/m-p/240301#M21</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been racking my memory for an answer to this is as I've had exactly the same thing happen but I can't remember how I resolved it.&amp;nbsp; Try changing timer1 to an unsigned short.&amp;nbsp; I know that doesn’t answer the question but there is something in my memory about it :smileyhappy:&amp;nbsp; If that works we can go from there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shaun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2014 09:32:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Digital-Signal-Controllers/Why-does-this-simple-conditional-misbehave-on-a-MC56F8006/m-p/240301#M21</guid>
      <dc:creator>yibbidy</dc:creator>
      <dc:date>2014-05-21T09:32:55Z</dc:date>
    </item>
  </channel>
</rss>

