Hi all,
Thank a lot IanP for your help .....
I want to ask you if you don't mind ....
The code should take the input from keypad and the output will be dispaly on the screen ....
I have a code which take for one pressing only so, how I can do it for using lookup table with multiple pressing ....... I am confusing with counters and delays
Can you see the code please and try to hep me if you don't mind ...
Thank you a lot ...
eime
The Code :
ORG 8100H ;Start location ....
MOV SP,#5FH ;Stack Pointer ....
MOV A, #10011001B ;Load the A=99H as output port(B)....
MOV DPTR,#0FF43H ;Control Register for the 8051 ....
MOVX @DPTR,A ;Move the value in A to data pointer ....
AGAIN: MOV A,#00001110B ;First row that we will check on it which digit is ON ....
MOV DPTR,#0FF41H ;Port B as output PORT ....
MOVX @DPTR,A
MOV DPTR,#0FF42H ;Port C as input PORT ....
MOVX A,@DPTR ;Move the value in A to data pointer ....
ANL A,#07H ;Anded the value which in A with 07H to get the first three bits ....
CJNE A,#6,OTHER ;Comparing the value in A with 6 if it isn't equal jump to other ....
MOV A,#'1' ;When the value in the A equal with 6 display Char '1' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 1 ....
OTHER: CJNE A,#5,L ;Comparing the value in A with 5 if it isn't equal jump to L ....
MOV A,#'2' ;When the value in the A equal with 5 display Char '2' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 2 ....
L: CJNE A,#3,N ;Comparing the value in A with 3 if it isn't equal jump to N is instead for the second row ....
MOV A,#'3' ;When the value in the A equal with 3 display Char '3' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 3 ....
N: MOV A,#00001101B ;Second row that we will check on it which digit is ON ....
MOV DPTR,#0FF41H ;Port B as output PORT ....
MOVX @DPTR,A
MOV DPTR,#0FF42H ;Port C as input PORT ....
MOVX A,@DPTR ;Move the value in A to data pointer ....
ANL A,#07H ;Anded the value which in A with 07H to get the first three bits ....
CJNE A,#6,OTHER1 ;Comparing the value in A with 6 if it isn't equal jump to other1 ....
MOV A,#'4' ;When the value in the A equal with 6 display Char '4' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 4 ....
OTHER1: CJNE A,#5,L1 ;Comparing the value in A with 5 if it isn't equal jump to L1 ....
MOV A,#'5' ;When the value in the A equal with 5 display Char '5' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 5 ....
L1: CJNE A,#3,N1 ;Comparing the value in A with 3 if it isn't equal jump to N1 is instead for the third row ....
MOV A,#'6' ;When the value in the A equal with 3 display Char '6' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 6 ....
N1: MOV A,#00001011B ;Third row that we will check on it which digit is ON ....
MOV DPTR,#0FF41H ;Port B as output PORT ....
MOVX @DPTR,A
MOV DPTR,#0FF42H ;Port C as input PORT ....
MOVX A,@DPTR ;Move the value in A to data pointer ....
ANL A,#07H ;Anded the value which in A with 07H to get the first three bits ....
CJNE A,#6,OTHER2 ;Comparing the value in A with 6 if it isn't equal jump to other2 ....
MOV A,#'7' ;When the value in the A equal with 6 display Char '7' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 7 ....
OTHER2: CJNE A,#5,L2 ;Comparing the value in A with 5 if it isn't equal jump to L2 ....
MOV A,#'8' ;When the value in the A equal with 5 display Char '8' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 8 ....
L2: CJNE A,#3,N2 ;Comparing the value in A with 3 if it isn't equal jump to N2 is instead for the forth row ....
MOV A,#'9' ;When the value in the A equal with 3 display Char '9' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 9 ....
N2: MOV A,#00000111B ;Forth row that we will check on it which digit is ON ....
MOV DPTR,#0FF41H ;Port B as output PORT ....
MOVX @DPTR,A
MOV DPTR,#0FF42H ;Port C as input PORT ....
MOVX A,@DPTR ;Move the value in A to data pointer ....
ANL A,#07H ;Anded the value which in A with 07H to get the first three bits ....
CJNE A,#6,OTHER3 ;Comparing the value in A with 6 if it isn't equal jump to other3 ....
MOV A,#'X' ;When the value in the A equal with 6 display Char 'X' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character X ....
OTHER3: CJNE A,#5,L3 ;Comparing the value in A with 5 if it isn't equal jump to L3 ....
MOV A,#'0' ;When the value in the A equal with 5 display Char '0' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 0 ....
L3: CJNE A,#3,N3 ;Comparing the value in A with 3 if it isn't equal jump to N3 ....
MOV A,#'#' ;When the value in the A equal with 3 display Char '#' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
N3: JMP AGAIN ;Jump to the main program after Displaying the character # ....
;##############################################################################################
;############################################# Delay Block ####################################
;##############################################################################################
DELAY: MOV R5,#4H ;DELAY FOR 0.5 SECOND ....
L31: MOV R6,#0FFH
L21: MOV R7,#0FFH
L11: DJNZ R7,L11
DJNZ R6,L21
DJNZ R5,L31
RET
ORG 9000H
LUP1: DB 'A','B','C'
LUP2: DB 'D','E','F'
END ;End the program ....