Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/29/08 06:20
Read: times


 
#154150 - use matrix keypad & timer interrupt
Responding to: ???'s previous message
Dear Jesmond,

From your problem it is clear that u r having 4x4 keypad. please follow the steps.

1. as you r using P0 ensure u have proper PULLUPs.
2. considor 1 nibble of P0 is row & another as colums. (for e.g. P0.0 to P0.3 are rows & P0.4 to P0.7 are columns).
3. In background keep scanning. each row by writing 0 & reading columns (this can be done best using timer 0/1 intterupt.)
4. For scanning rows; write 1's on all columns & rows (P0 = 0xFF). now make row0 = 0 (i.e.P0.0 = 0 => P0 = 0xFE).
5. Now give some 'nops'(depending on pullups & osc. freq) & again read port. If all colomns are 1's then no key is pressed. come out of ISR. if any of column is zero then keep that in memory. come out of ISR.
6. In next ISR scan row1 instead (i.e. P0.1 = 0 or P0 = 0xFD). similarly scan row2 & row3 in consugative ISR.
7. when u come back to same row where u find key pressed last time, compare read no. with previous 1, stored in memory.(remember P0 when read will have maximum of 2 zeros)
8. if no. matches for minimum of 20 to 50 mSecs it is a valid key.


I hope this will help you.

List of 11 messages in thread
TopicAuthorDate
4x4 keypad            01/01/70 00:00      
   Which part are you stuck with?            01/01/70 00:00      
      4x4 keypad.            01/01/70 00:00      
         Do you understand how the matrix works?            01/01/70 00:00      
         use matrix keypad & timer interrupt            01/01/70 00:00      
            code for your keyboard.            01/01/70 00:00      
   C code for your keypad            01/01/70 00:00      
      C code for your keypad - do not use            01/01/70 00:00      
         Eric, you must have good eyesight            01/01/70 00:00      
            naah, I spotted the basic error immediately, ...            01/01/70 00:00      
      How to post source code            01/01/70 00:00      

Back to Subject List