<?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: debounced switch detect on key release</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140537#M5651</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Sounds a very comprehensive piece of code. Probably a bit over the top for my purpose but thanks anyway.&lt;BR /&gt;&lt;BR /&gt;I'm writing in C although my background is assembler.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Jul 2007 15:49:27 GMT</pubDate>
    <dc:creator>stevec</dc:creator>
    <dc:date>2007-07-19T15:49:27Z</dc:date>
    <item>
      <title>debounced switch detect on key release</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140535#M5649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have 7 switches on a port which I need to debounce but need to register the key release as well as how long the key was pressed for (could be up to 3 seconds). I believe a passing reference was made by tonyp to this in a previous thread. I shall&amp;nbsp; be using a background tick interval to sample the switches rather than the KBI (although the switches are connected to the KBI port for waking the processor up). Has anyone any method to do this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jul 2007 13:37:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140535#M5649</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2007-07-19T13:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: debounced switch detect on key release</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140536#M5650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Hi Steve,&lt;BR /&gt;&lt;BR /&gt;I have a message-based key decoder that runs as a background task, sampling the switches when scheduled to do so by a timer interrupt. Its features are:&lt;BR /&gt;&lt;BR /&gt;It currently supports 16 switches on two ports, but expandable, if needed.&lt;BR /&gt;Differentiates between a switch being 'clicked' and a switch being 'held'.&lt;BR /&gt;The time-difference between a 'clicked' switch and a 'held' switch is selectable.&lt;BR /&gt;Keys can be programmed auto-repeat.&lt;BR /&gt;Supports an unlimited amount of key rollover.&lt;BR /&gt;Messages are issued when any key event occurs. The key events are:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;KeyPressed:&amp;nbsp;&amp;nbsp; the key was pressed down&lt;BR /&gt;KeyClicked:&amp;nbsp;&amp;nbsp; the key was pressed and released quickly&lt;BR /&gt;KeyHeld: &amp;nbsp; the key has been pressed long enough to be 'Held' (typically 1 second)&lt;BR /&gt;KeyRepeat: &amp;nbsp; the key has been down for an additional 1/4 second (time is selectable)&lt;BR /&gt;KeyHoldEnd: &amp;nbsp; the key was 'Held', but is now released&lt;BR /&gt;KeyReleased: &amp;nbsp; the key was let back up&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;Some actions can generate more than one message. As an example, when a key is released a "KeyReleased" message will be issued, but either a "KeyClicked" or "KeyHoldEnd" will also be issued, depending on how long the key was down. This way, the receiving task can decide which messages it cares about.&lt;BR /&gt;&lt;BR /&gt;I'm not sure if this is what you want to get into, but if it is I can post the code. It is written to run as a task, not as an ISR. A timer interrupt queues it up to my nano-scheduler, which then runs it.&lt;BR /&gt;&lt;BR /&gt;Oops, I forgot to ask if you needed C or assembly language. My code is written in assembly language.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jul 2007 15:13:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140536#M5650</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2007-07-19T15:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: debounced switch detect on key release</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140537#M5651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Sounds a very comprehensive piece of code. Probably a bit over the top for my purpose but thanks anyway.&lt;BR /&gt;&lt;BR /&gt;I'm writing in C although my background is assembler.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jul 2007 15:49:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140537#M5651</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2007-07-19T15:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: debounced switch detect on key release</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140538#M5652</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;FONT size="2"&gt;Hello Steve,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Where all keyswitches are contiguously allocated on a single port, I have previously used the following polling method within the main loop.&amp;nbsp; For the purpose of the discussion, I will assume that all eight inputs have switches connected.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I use a timer to set a "cycle flag", and when the flag is set, the processing of keyswitch closures is performed.&amp;nbsp; For simplicity, the cycle period should be suitable for key de-bounce (typically 20 - 100 ms) - I might use timer overflow interrupt for this purpose.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;To simplify the de-bounce process, when one or more inputs changes state,&amp;nbsp;it is&amp;nbsp;required that&amp;nbsp;the next sample&amp;nbsp;of all the inputs should have the same&amp;nbsp;state.&amp;nbsp; If the two states differ, transient operation is assumed.&amp;nbsp; This should be satisfactory for mechanical switches, where switch activity is not rapid.&amp;nbsp; The sample when a change is first detected, is called "phase 0", and the subsequent sample "phase 1".&amp;nbsp; This is controlled by a&amp;nbsp;phase flag bit.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The attached code attempts to demonstrate this operation.&amp;nbsp; To determine the period that each keyswitch remains active,&amp;nbsp;an array variable is used&amp;nbsp;to provide a separate timer value for each switch - this is incremented each cycle.&amp;nbsp; Additional code would need to be provided for the following&amp;nbsp;functions -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;void key_on(byte key);&amp;nbsp; /* Turn-on processing for each key */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;void key_off(byte key, word time);&amp;nbsp; /* Turn-offf processing for each key */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2007-07-20&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;03:55 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jul 2007 00:53:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140538#M5652</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-07-20T00:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: debounced switch detect on key release</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140539#M5653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Rocco;&lt;BR /&gt;&amp;nbsp;I'd like to request a copy of your keyboard decoding routine(s) in assembly format. This application sounds really interesting and I'd like to look at it.&lt;BR /&gt;Regards, Bob&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2007 09:10:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140539#M5653</guid>
      <dc:creator>BobMac</dc:creator>
      <dc:date>2007-07-26T09:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: debounced switch detect on key release</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140540#M5654</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;Hi Bob,&lt;BR /&gt;&lt;BR /&gt;Sorry for the delay, I was on location for a few days.&lt;BR /&gt;&lt;BR /&gt;Here is a copy of the 'KeyPad' routine, as well as my task dispatch routine and the appropriate macros. If I have left anything out, let me know.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by rocco on &lt;SPAN class="date_text"&gt;2007-07-27&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;06:12 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jul 2007 08:12:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140540#M5654</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2007-07-28T08:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: debounced switch detect on key release</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140541#M5655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Well, I did leave out something.&lt;BR /&gt;&lt;BR /&gt;I forgot to mention that this code was written for McuEZ, Freescale's predecessor to CodeWarrior. I was told that it should be compatible, as CodeWarrior uses the same assembler and linker, but I have never been able to verify that.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Jul 2007 03:06:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140541#M5655</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2007-07-29T03:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: debounced switch detect on key release</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140542#M5656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Rocco;&lt;BR /&gt;&amp;nbsp;Thanks for the listing! I really enjoyed reading it. The reason I sent you two e-mails was I wasn't sure the first one was sent correctly.&lt;BR /&gt;&lt;BR /&gt;Best regards, BobMac&lt;BR /&gt;&lt;BR /&gt;PS, I'll have to ask our moderator about a spelling checker sometime. Like where to find it? I'm sure Freescale &lt;I&gt;&lt;B&gt;must&lt;/B&gt;&lt;/I&gt; have bought and included one somewhere ;o)&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jul 2007 08:45:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/debounced-switch-detect-on-key-release/m-p/140542#M5656</guid>
      <dc:creator>BobMac</dc:creator>
      <dc:date>2007-07-30T08:45:24Z</dc:date>
    </item>
  </channel>
</rss>

