We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
keyboard_scaning , which interval is 50ms I use 10 milliseconds Typically the long periods between scanning the keys is due to fully scanning them every time which eat up a lot of processing time. The "trick" is to do the timer isr this way px = all columns enabled if (.....) some column active { ... do a full scan } else { key = 0 } get out of ISR This way any significant time is only eaten when a key is actually pressed You do, of course, process the variable "key" somewhere in the main. Erik
I have found the article. Thank you very much!
This may be of interest: http://www.programmersheaven.com/zone5/cat27/35789.htm