<?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: Faster way for IF() and Adding? in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580819#M24697</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Dave3891 on Tue Jun 21 21:24:32 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the tip, changing it to a uint32 got it down 5 more cycles to 41 each.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 02:36:29 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T02:36:29Z</dc:date>
    <item>
      <title>Faster way for IF() and Adding?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580812#M24690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Dave3891 on Sun Jun 19 09:58:24 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a faster way to do this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;[SIZE=2]
[LEFT]error2 -= cp2;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](error2 &amp;lt; 0 ){
error2 += cp1;
LPC_GPIO2-&amp;gt;[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MASKED_ACCESS[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][(1&amp;lt;&amp;lt;4)] = (1&amp;lt;&amp;lt;4);
position2++;[/LEFT]
}
[/SIZE]&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;It takes about 70 clock cycles to do this operation and I need to use 6 of these within a timer interrupt, and I cant speed up my timer freq without speeding up this operation. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dave&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:36:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580812#M24690</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way for IF() and Adding?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580813#M24691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by gbm on Sun Jun 19 12:31:58 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;As the code is trivial, the only operation that could take some significant time is the GPIO access. If you need to set several IO pins in a single port, make a mask variable, OR it with all active bit masks and then do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[SIZE=2]LPC_GPIO2-&amp;gt;[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MASKED_ACCESS[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][mask] = mask;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually [/SIZE][SIZE=2]LPC_GPIO2-&amp;gt;[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MASKED_ACCESS[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][mask] = 0xffffffff; would do the same&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/SIZE]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:36:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580813#M24691</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way for IF() and Adding?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580814#M24692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by igorsk on Mon Jun 20 04:26:27 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you using Release build? Are any of those variable floating-point?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:36:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580814#M24692</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way for IF() and Adding?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580815#M24693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Dave3891 on Mon Jun 20 15:09:39 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;They are all uint16_t and it is a debug build. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;70 cycles seems like alot for 2 add's a subtract and a IF. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How would I view what is being done by the compiler in assembly code?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:36:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580815#M24693</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way for IF() and Adding?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580816#M24694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Mon Jun 20 15:32:36 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;...Release build?&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... was a little hint to use optimization :)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://support.code-red-tech.com/CodeRedWiki/CompilerOptimization&lt;/A&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;How would I view what is being done by the compiler in assembly code? &lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://support.code-red-tech.com/CodeRedWiki/DebugViewAsm?highlight=%28assembly%29&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:36:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580816#M24694</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way for IF() and Adding?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580817#M24695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Dave3891 on Mon Jun 20 23:09:17 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Well I changed it to &lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;[SIZE=2]
[LEFT]error2 -= cp2;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](error2 &amp;lt; 0 ){
error2 += cp1;
mask2 |= (1&amp;lt;&amp;lt;4);
position2++;[/LEFT]
}
[/SIZE]&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;with a single mask access at the end of the 6 sets and used max optimization and it looks like its down to about 46 cycles each.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Does that sound about right?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:36:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580817#M24695</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way for IF() and Adding?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580818#M24696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by igorsk on Tue Jun 21 04:15:37 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Use int or uin32_t variables. With uint16_t, the compiler has to do extra work to trim the range after each operation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:36:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580818#M24696</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way for IF() and Adding?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580819#M24697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Dave3891 on Tue Jun 21 21:24:32 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the tip, changing it to a uint32 got it down 5 more cycles to 41 each.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:36:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Faster-way-for-IF-and-Adding/m-p/580819#M24697</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:36:29Z</dc:date>
    </item>
  </channel>
</rss>

