??? 09/16/06 07:50 Read: times |
#124396 - Maybe the problem is not here Responding to: ???'s previous message |
We've told you where the problem is - but you haven't attended to it. I'm sure if you put your code through a simulator, you'd see exactly where your problem is. Try this for some hints. The delay should be a few 10's of microseconds. Do you have pullup resistors on P1.0..3? If so, what value. [pre] ROW1 .equ efh ROW2 .equ dfh ROW3 .equ bfh ROW4 .equ 7fh scan_keypad: mov R2,#0 ;keys 0..3 mov P1,ROW1 ;select row 1 acall delay ;wait for things to settle mov a,P1 anl a,#0fh ;columns only jnz test_column mov R2,#4 ;keys 4..7 mov P1,ROW2 ;select row 2 acall delay ;wait for things to settle mov a,P1 anl a,#0fh ;columns only jnz test_column mov R2,#8 ;keys 8..11 mov P1,ROW3 ;select row 3 acall delay ;wait for things to settle mov a,P1 anl a,#0fh ;columns only jnz test_column mov R2,#12 ;keys 12..15 mov P1,ROW4 ;select row 4 acall delay ;wait for things to settle mov a,P1 anl a,#0fh ;columns only jnz test_column mov a,#NO_KEY ;no key was pressed ret [/pre] |