Hi,
Below is a simple keyboard program, where i need to lock in 3 numeric digits only. The user will exit the program by pressing a non-numeric key. Until then, he can press any no. of keys. the program also displays each key properly as each one is pressed.
Problem: the program is unable to lock in the 3 digits from the key board. A similar program minus the keyboard, but using internal stored data works fine. Where is the problem ? I am using 89s52 an uvision ide. Can somebody reply please ?
ENDATA EQU #70H KEYBOARD: MOV R0, #03H ; PICK UP 3 DIGITS ONLY MOV R1, #ENDATA ;WRITE THE DATA IN TO MEMORY KEYBOARDDET: ; ONLY FOR NUMERIC. PRESSING 'D' RETURNS TO MAIN MOV P1, #11111111B ; INPUT FOR KB ;1ST ROW CLR P1.7 // makes row 1 low JB P1.3,NEXT1 // checks whether column 1 is low and jumps to NEXT1 if not low MOV A,#01H // loads a with 0D if column is low (that means key 1 is pressed) LCALL DISPLAYKB LJMP STORE ; STORE DATA IN MEMORY. NEXT1:JB P1.2, NEXT2 // checks whether column 2 is low and so on... MOV A,#02H LCALL DISPLAYKB ; DISPLAYKB IS USED TO DISPLAY THE DIGIT PRESSED LJMP STORE NEXT2:JB P1.1, NEXT3 MOV A,#03H LCALL DISPLAYKB LJMP STORE ;2ND ROW NEXT3:SETB P1.7 CLR P1.6 JB P1.3,NEXT4 MOV A,#04H LCALL DISPLAYKB LJMP STORE NEXT4:JB P1.2,NEXT5 MOV A,#05H LCALL DISPLAYKB LJMP STORE NEXT5:JB P1.1,NEXT6 MOV A,#06H LCALL DISPLAYKB LJMP STORE ;3RD ROW NEXT6:SETB P1.6 CLR P1.5 JB P1.3,NEXT7 MOV A,#07H LCALL DISPLAYKB LJMP STORE NEXT7:JB P1.2,NEXT8 MOV A,#08H LCALL DISPLAYKB LJMP STORE NEXT8:JB P1.1,NEXT9 MOV A,#09H LCALL DISPLAYKB LJMP STORE ;4TH ROW NEXT9: SETB P1.5 CLR P1.4 JB P1.2,NEXT10 MOV A,#00H LCALL DISPLAYKB LJMP STORE NEXT10:JB P1.0, GOBACK LJMP DISPLAY ; press 'D'to exit the program and display 3 digits GOBACK: LJMP KEYBOARDDET STORE: ; STORE 3 numeric digits IN ENDATA MOV @R1, A DEC R1 DJNZ R0, CALLDET LJMP KEYBOARD CALLDET: LJMP KEYBOARDDET
.