<?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>8-bit Microcontrollers中的主题 Re: developing switch bounce delay</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141589#M5969</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Bud wrote:&lt;BR /&gt;&lt;DIV&gt;There seems to be 2 ways to handle switch debounce when you want to read into a port. One is to develop a delay loop the second is to utilize a timer. the delay loop is fairly easy.. how do I initialize a timer to be randomly called only when I want to debounce the switch? I am utilizing a 9sc08gt16 processor.&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;Bud&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hello Bud.&lt;BR /&gt;This is a problem that I have to solve for just about every application I do. I have a standardized way of doing it, but it only works if you have a periodic interrupt going on (say a 'real-time' interrupt every milisecond). It works like this:&lt;BR /&gt;1. Assume we have 8 switch inputs on port A&lt;BR /&gt;2. Assume we want a de-bounce time of 50 miliseconds&lt;BR /&gt;3. Assume we've assigned variables temp_switch and valid_switch and bounce_time&lt;BR /&gt;4. Assume the processor init routine will clear temp_switch and valid_switch and place $32 in bounce_time.&lt;BR /&gt;Now the process:&lt;BR /&gt;A) every time the periodic interrupt executes it reads port A and compares it with the contents of temp_switch.&lt;BR /&gt; If not the same copy port A to temp_switch and init bounce_time to $32 and leave&lt;BR /&gt; Else if bounce_time is non zero decrement it and leave&lt;BR /&gt; Else if bounce_time is zero copy temp_switch to valid_switch and leave&lt;BR /&gt;&lt;BR /&gt;This technique debounces any change of state for the 8 port A inputs and has the advantage that your main program can treat the contents of valid_switch as 'gospel' switch info.&lt;BR /&gt;ron&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Jun 2006 10:56:18 GMT</pubDate>
    <dc:creator>glork</dc:creator>
    <dc:date>2006-06-30T10:56:18Z</dc:date>
    <item>
      <title>developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141588#M5968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;There seems to be 2 ways to handle switch debounce when you want to read into a port.&amp;nbsp; One is to develop a delay loop the second is to utilize a timer.&amp;nbsp; the delay loop is fairly easy.. how do I initialize a timer to be randomly called only when I want to debounce the switch? I am utilizing a 9sc08gt16 processor.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;Bud&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jun 2006 10:06:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141588#M5968</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2006-06-30T10:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141589#M5969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Bud wrote:&lt;BR /&gt;&lt;DIV&gt;There seems to be 2 ways to handle switch debounce when you want to read into a port. One is to develop a delay loop the second is to utilize a timer. the delay loop is fairly easy.. how do I initialize a timer to be randomly called only when I want to debounce the switch? I am utilizing a 9sc08gt16 processor.&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;Bud&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hello Bud.&lt;BR /&gt;This is a problem that I have to solve for just about every application I do. I have a standardized way of doing it, but it only works if you have a periodic interrupt going on (say a 'real-time' interrupt every milisecond). It works like this:&lt;BR /&gt;1. Assume we have 8 switch inputs on port A&lt;BR /&gt;2. Assume we want a de-bounce time of 50 miliseconds&lt;BR /&gt;3. Assume we've assigned variables temp_switch and valid_switch and bounce_time&lt;BR /&gt;4. Assume the processor init routine will clear temp_switch and valid_switch and place $32 in bounce_time.&lt;BR /&gt;Now the process:&lt;BR /&gt;A) every time the periodic interrupt executes it reads port A and compares it with the contents of temp_switch.&lt;BR /&gt; If not the same copy port A to temp_switch and init bounce_time to $32 and leave&lt;BR /&gt; Else if bounce_time is non zero decrement it and leave&lt;BR /&gt; Else if bounce_time is zero copy temp_switch to valid_switch and leave&lt;BR /&gt;&lt;BR /&gt;This technique debounces any change of state for the 8 port A inputs and has the advantage that your main program can treat the contents of valid_switch as 'gospel' switch info.&lt;BR /&gt;ron&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jun 2006 10:56:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141589#M5969</guid>
      <dc:creator>glork</dc:creator>
      <dc:date>2006-06-30T10:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141590#M5970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi Bud,&lt;/P&gt;&lt;P&gt;Now that you have quantified the ways, others will suggest more! &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;P&gt;If you have a spare timer, you can scale it and set the modulo to get your delay.&lt;/P&gt;&lt;P&gt;Then when you see the switch operate :&lt;/P&gt;&lt;P&gt;Read TPMxSC to help next step&lt;/P&gt;&lt;P&gt;Clear TOF inTPMxSC&lt;/P&gt;&lt;P&gt;Write to TPMxCNTH to reset counter&lt;/P&gt;&lt;P&gt;Now you can wait for TOF to become set or get it to generate an interrupt&lt;/P&gt;&lt;P&gt;Don't clear TOF as you normally would when you service this.&lt;/P&gt;&lt;P&gt;Then perform the intended switch response. (if you did not do it when you first detected closure)&lt;/P&gt;&lt;P&gt;This method saves having to do the 16-bit adds.&lt;/P&gt;&lt;P&gt;Regards David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message Edited by peg on &lt;SPAN class="date_text"&gt;2006-06-30&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;03:11 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jun 2006 11:00:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141590#M5970</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-06-30T11:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141591#M5971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;See, there you go, even before I finished typing method 3 arrives!&lt;/P&gt;&lt;P&gt;Some comments on this method though:&lt;/P&gt;&lt;P&gt;1. switch needs to remain down at the end of debounce. (not always an issue)&lt;/P&gt;&lt;P&gt;2. if a second switch changes state within the firsts debounce the debounce can be extended to double length (now it has to be down for 2 x debounce time)&lt;/P&gt;&lt;P&gt;3. You don't get to react to the closure until after the debounce time (or 2?).&lt;/P&gt;&lt;P&gt;If it is a keypad or array of finger operated buttons this is not a problem, but if they are machine switches etc this could cause havoc.&lt;/P&gt;&lt;P&gt;You will notice I avoided scrutiny by only answering the exact question about implementing the timer.&lt;/P&gt;&lt;P&gt;This is one of those subjects that a first seem innocuous but can be quite complicated and dependant on many other things.&lt;/P&gt;&lt;P&gt;Regards David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message Edited by peg on &lt;SPAN class="date_text"&gt;2006-06-30&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;03:13 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jun 2006 12:06:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141591#M5971</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-06-30T12:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141592#M5972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Bud,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;To generate&amp;nbsp;non-critical time delays, such as for switch debounce, LED flashing, etc, there are a couple of simple methods using the timer.&amp;nbsp; The first uses a periodic interrupt such as RTI or timer overflow.&amp;nbsp; The second method requires simply to read the timer count register, and does not specifically require any interrupts to be enabled.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Method 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The periodic interrupt should occur multiple times within the timeout period - the actual timeout period will have an uncertainty of one interrupt period (i.e. +/- one half period).&amp;nbsp; Allocate one or more global variables (of byte or word size), one variable for each simultaneous timeout that may need to occur, say &lt;FONT face="Courier New"&gt;timeout1, timeout2.&lt;/FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Within the timer ISR place the following code for each variable, to decrement the variable unless already zero.&lt;BR /&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; if (timeout1)&amp;nbsp; timeout1 -= 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (timeout2)&amp;nbsp; timeout2 -= 1;&lt;BR /&gt;etc.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Arial"&gt;&lt;FONT size="2"&gt;Then within the main program, where you need&amp;nbsp;the timeout&amp;nbsp;delay period, the following code should work.&lt;BR /&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; for (timeout1 = DEBOUNCE; timeout1; );&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size="2"&gt;&lt;FONT face="Arial"&gt;or alternatively&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; timeout1 = DEBOUNCE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; while (timeout1);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Arial"&gt;&lt;FONT size="2"&gt;Method 2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Arial"&gt;&lt;FONT size="2"&gt;If the timer overflow method should have insufficient resolution because the overflow period is too long&amp;nbsp;(and you do not wish to alter timer settings for other reasons), simply chose a bit within the timer count register (TCR) that toggles at a suitable rate, and use this as the basis for decrementing a timeout variable.&amp;nbsp; The following example uses bit 9 for the timing.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; #define MASK 0x0100&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; for (timeout1 = DEBOUNCE; timeout; ) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (TCR &amp;amp; MASK == 0);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (TCR &amp;amp; MASK);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timeout1--;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="+0"&gt;&lt;FONT size="+0"&gt;&lt;FONT size="2"&gt;I hope this provides some ideas.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="+0"&gt;&lt;FONT size="+0"&gt;&lt;FONT size="2"&gt;Regards Mac&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="+0"&gt;&lt;FONT size="+0"&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2006-06-30&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;04:59 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jun 2006 13:49:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141592#M5972</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-06-30T13:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141593#M5973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;In addition to the other great responses you've received:&lt;/P&gt;&lt;P&gt;I often use dual (and occasionally triple) functions per key (I'll describe dual here.) This saves component count and cost in smaller cost-sensitive applications.&lt;/P&gt;&lt;P&gt;You can &lt;STRONG&gt;have the same key invoke different actions on short and long&lt;/STRONG&gt; (or short, medium, and long) &lt;STRONG&gt;presses&lt;/STRONG&gt;.&amp;nbsp; I normally use &amp;lt;2 sec for short, and &amp;gt;5 sec for long.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The shorter presses can be acknowledged only on releasing the key because you can't know if the user intends to keep it pressed even longer for the next function.&amp;nbsp; This means &lt;STRONG&gt;you need to debounce both key-down and key-up to save you from the possibility of noise appearing as a (premature) release,&lt;/STRONG&gt; using similar methods to those described in other replies.&lt;/P&gt;&lt;P&gt;The longest key can be acknowledged regardless of&amp;nbsp;a release but I prefer to wait for a release anyway which also gives me an indication of&amp;nbsp;possible stuck-key errors (indefinite presses), if it doesn't happen within some reasonable time.&amp;nbsp; So, in reality, there is always an extra quite long "hidden" key which is returned as KeyError.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jun 2006 17:40:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141593#M5973</guid>
      <dc:creator>tonyp</dc:creator>
      <dc:date>2006-06-30T17:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141594#M5974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Is the simple software delay suitable for real world applications?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Since the&amp;nbsp;debounce&amp;nbsp;is specific for each type of switch, the bounce needs to be studied&amp;nbsp;for the best debounce technique.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Jul 2006 12:02:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141594#M5974</guid>
      <dc:creator>FC</dc:creator>
      <dc:date>2006-07-01T12:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141595#M5975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;FC wrote:&lt;BR /&gt;&lt;DIV&gt;Is the simple software delay suitable for real world applications?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Since the&amp;nbsp;debounce&amp;nbsp;is specific for each type of switch, the bounce needs to be studied&amp;nbsp;for the best debounce technique.&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;Yes, normally it is. The debounce time is usually inversly proportional to the cost of the switch. Good quality keypad switches can be safely debounced in 10-15ms.&lt;/P&gt;&lt;P&gt;What else did you have in mind for the "real world applications" where you think it wouldn't work?&lt;/P&gt;&lt;P&gt;If you can't debounce it in 100ms you should probably looking at a different switch rather than more complex code as the "bounce" time will probably only get worse with time.&lt;/P&gt;&lt;P&gt;Regards David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Jul 2006 16:25:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141595#M5975</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-07-01T16:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141596#M5976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Is the simple software delay suitable for real world applications?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;I am told that the "real world" is where the walls are not padded. I do not know for sure, since they won't let me out to see it.&lt;BR /&gt;&lt;BR /&gt;The routine I use works for any switch, regardless of how long it bounces. I sample at a fixed rate (driven by a timer interrupt), and only register a change when the switch has been the same for five milliseconds. This will work for a 2 millisecond switch or a 100 millisecond switch.&lt;BR /&gt;&lt;BR /&gt;The code is here on the board somewhere.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Jul 2006 00:26:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141596#M5976</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-07-02T00:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141597#M5977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Yes it will work 100%&amp;nbsp;with a 2ms switch and very reliable for a 5, 10 15. But as you approach 100 the reliability of proper detection falls away as the probability of sampling at 5 discrete times in a row when the switch is in the bounced state rises.&lt;/P&gt;&lt;P&gt;The "padding" in the timer method eliminates this.&lt;/P&gt;&lt;P&gt;This method also works as a noise/glitch filter as well, although if you have noise/glitches that can cause a state change on an input you probably should be looking elsewhere.&lt;/P&gt;&lt;P&gt;I am not saying it is bad concept, I use both basic methods myself, where appropriate.&lt;/P&gt;&lt;P&gt;Regards David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message Edited by peg on &lt;SPAN class="date_text"&gt;2006-07-02&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;12:21 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Jul 2006 06:15:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141597#M5977</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-07-02T06:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141598#M5978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Actually, David, I have never really seen a switch bounce for 100 milliseconds, so I can't really say that it would work at that extreme. But it does work reliably for the worst switch I ever had, which varied between 25 and 35 milliseconds (an old military-style toggle).&lt;BR /&gt;&lt;BR /&gt;My experience is that, when a switch bounces, it keeps bouncing for the entire debounce period. They don't seem to stop to rest.&lt;BR /&gt;&lt;BR /&gt;I like to sample at a 200 microsecond rate, which means you would need 25 samples, all at the same level, before you decided that the switch has stopped bouncing.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Jul 2006 13:55:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141598#M5978</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-07-02T13:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141599#M5979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Fair enough!&lt;/P&gt;&lt;P&gt;Somehow I got it in to my head that you were sampling at 1ms rate which led me to comment as I did. 25 consecutive samples of an uncontrolled frequency source would be impossible enough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Jul 2006 14:16:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141599#M5979</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-07-02T14:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: developing switch bounce delay</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141600#M5980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;To date, I've just been using software timers and large state machines to give me various styles of switch detection. E.g., long and short times for multiple functions, action taken while switch is still depressed, action taken after up debounce, etc.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jul 2006 02:29:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/developing-switch-bounce-delay/m-p/141600#M5980</guid>
      <dc:creator>irob</dc:creator>
      <dc:date>2006-07-06T02:29:39Z</dc:date>
    </item>
  </channel>
</rss>

