On a keyboard,a key include 4 letters ,likes '1','A','B','C' being input in different time by a key.I use Timer0 interrupt service routine as a keyboard_scaning , which interval is 50ms and a valid char will be scaned two times.and i use Timer1 as delay_counter .for example,scaning '1' Key the first time by T0_isr,key_temp is '1',release '1' key and closed immediately ,just the same key be scaned the second time,key_temp is 'A'.when the key release ,Timer1 is enabled.the T1_isr will give a valid Key 'A' to main program after the delay_time.It is clearly a delay_time between key_releasing to Timer1 flowing to ensure the Key 'A' is valid. In the other words ,every Key must wait for delay_time when input. and now ,I want not to waiting the delay_time if the next closed Key is not the same previous Key,how can cancel delay_time between two different Keys? Can you tell me how to do ?Have any source code for example? Best regards, Nantiangumo
Nantian, What you are trying to do (reading a key twice to "make sure" it was pressed) is called "debouncing." It's a more in-depth subject than you might expect. The following is a link to an article from embedded systems programming about software debouncing that's based on the author's studies of switch output waveforms etc. It includes example code which you could adapt to your system. http://www.embedded.com//showArticle.jhtml?articleID=22100235
I have found the article. Thank you very much!