If the key is so poor that it has more than a 10ms bounce, then perhaps the time constant of the test needs to be increased. The routine itself is bulletproof using the pattern b'11110000', indicating that it was low for 4 cycles then was high for 4 cycles. --Bob Michael Rigby-Jones wrote: >>-----Original Message----- >>From: Bob Axtell [mailto:cr_axtell@YAHOO.COM] >>Sent: 18 June 2004 18:59 >>To: PICLIST@MITVMA.MIT.EDU >>Subject: Re: [PIC]: anding/masking {handling keys} >> >>About 10 years ago I began using a bulletproof way to process keys: >> >>1. I read the keys- all of them- every 10ms or so. I can >>either read 'em all at one tome, or rotate so that I read each >>one on a rotating basis. Doesn't matter how its done, it works >>perfectly regardless. >> >>2. Every 10ms I read the key and shift its value into a >>register decicated just for that application. >> >>3. If the key is ZERO when it is pressed, I look for the >>pattern b'11110000' on that key's register. When that is seen, >>that key was PRESSED AND RELEASED, so set a flag. To prevent >>more action, jam the key's register with '11111111' so it >>can't be used again. > > > I'm not convinced of the "bulletproofness" of this technique. If the switch > in question has a bounce time of more than 10ms (which isn't uncommon), you > may never get the exact bit pattern you are looking for, and the keypress > would never be registered. > > Regards > > Mike > > > > > ======================================================================= > This e-mail is intended for the person it is addressed to only. The > information contained in it may be confidential and/or protected by > law. If you are not the intended recipient of this message, you must > not make any use of this information, or copy or show it to any > person. Please contact us immediately to tell us that you have > received this e-mail, and return the original to us. Any use, > forwarding, printing or copying of this message is strictly prohibited. > No part of this message can be considered a request for goods or > services. > ======================================================================= > Any questions about Bookham's E-Mail service should be directed to > postmaster@bookham.com. > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > -- Replier: Most attachments rejected -------------- Bob Axtell PIC Hardware & Firmware Dev http://beam.to/baxtell 1-520-219-2363 -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.