<?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>LPC MicrocontrollersのトピックStopWatch_DelayXs doesn't bear in mind timer overrun?</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/StopWatch-DelayXs-doesn-t-bear-in-mind-timer-overrun/m-p/583460#M20854</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by 1234567890 on Thu Jan 01 04:31:41 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Because LPCOpen contains no 'StopWatch' for LPC11xx yet I started to implement it with code from LPC17xx. Just adapting the used timer and so on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But: StopWatch_DelayXs uses 32 bit &lt;/SPAN&gt;&lt;STRONG&gt;un&lt;/STRONG&gt;&lt;SPAN&gt;signed integers. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For convinience let's have a look with 4 bit unsigned integers. The variable 'ticks' to delay has been calculated to uint4_t 0x9.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;StopWatch_DelayXs starts with reading the actual timer value as reference. Let's assume a current timer value of startTime = uint4_t 0xF.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the while-loop the expression 'current timer value - startTime &amp;lt; ticks' is evaluated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Let's assume&amp;nbsp; 'current timer value' is now uint4_t 0x0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then '0x0 - 0xF &amp;lt; 0x9' is evaluated. This should be evaluated to 'FALSE' and the whille loop is terminated much too early.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did I have too much Champagne last night or is this the case?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:22:35 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:22:35Z</dc:date>
    <item>
      <title>StopWatch_DelayXs doesn't bear in mind timer overrun?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/StopWatch-DelayXs-doesn-t-bear-in-mind-timer-overrun/m-p/583460#M20854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by 1234567890 on Thu Jan 01 04:31:41 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Because LPCOpen contains no 'StopWatch' for LPC11xx yet I started to implement it with code from LPC17xx. Just adapting the used timer and so on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But: StopWatch_DelayXs uses 32 bit &lt;/SPAN&gt;&lt;STRONG&gt;un&lt;/STRONG&gt;&lt;SPAN&gt;signed integers. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For convinience let's have a look with 4 bit unsigned integers. The variable 'ticks' to delay has been calculated to uint4_t 0x9.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;StopWatch_DelayXs starts with reading the actual timer value as reference. Let's assume a current timer value of startTime = uint4_t 0xF.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the while-loop the expression 'current timer value - startTime &amp;lt; ticks' is evaluated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Let's assume&amp;nbsp; 'current timer value' is now uint4_t 0x0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then '0x0 - 0xF &amp;lt; 0x9' is evaluated. This should be evaluated to 'FALSE' and the whille loop is terminated much too early.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did I have too much Champagne last night or is this the case?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:22:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/StopWatch-DelayXs-doesn-t-bear-in-mind-timer-overrun/m-p/583460#M20854</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:22:35Z</dc:date>
    </item>
  </channel>
</rss>

