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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/29/05 14:40
Modified:
  09/29/05 14:43

Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#101724 - Compiles & Lined OK with CAS.EXE
Responding to: ???'s previous message
Hello Pritam,

Below is your code and hex file compiled with CAS.EXE (a public domain 8051 compiler program).

Regards,

Charles Bannister

;;	hi all,
;;	I hav written one code for interfacing 4X4 matrix keypad which is as follows
;;	Keyboard subroutine. This program sends the ASCII code
;;	for pressed key to P0
;;	P1.0-P1.3 connected to rows, P2.0-P2.3 connected to columns
;;
;;	After assembling the code i m getting erros as "Undefined opcode"
;;	for the 4-lines of look up table. I m not able to correct my
;;	mistakes. so plz can anybody help me out to correct these errors.
;;	Also tel me what mistake is been done exactly.
;;	Waiting for reply.
;;
;;	Pritam

ORG 0x00

       MOV P2,#0FFH	      ;;make P2 an input port
K1:    MOV P1,#0	      ;;ground all rows at once
       MOV A,P2 	      ;;read all col. (ensure all keys open)
       ANL A,00001111B	      ;;masked unused bits
       CJNE A,#00001111B,K1   ;;check til all keys released
K2:    ACALL TIME
       ACALL DELAY	      ;;call 20 msec delay
       MOV A,P2 	      ;;see if any key is pressed
       ANL A,#00001111B       ;;mask unused bits
       CJNE A,#00001111B,OVER ;;key pressed, await closure
       SJMP K2		      ;;check il key pressed
OVER:  ACALL TIME
       ACALL DELAY	      ;;wait 20 msec debounce time
       MOV A,P2 	      ;;check key closure
       ANL A,#00001111B       ;;mask unused bits
       CJNE A,#00001111B,OVER1;;key pressed, find row
       SJMP K2		      ;;if none, keep polling
OVER1: MOV P1,#11111110B      ;;ground row 0
       MOV A,P2 	      ;;read all columns
       ANL A,#00001111B       ;;mask unused bits
       CJNE A,#00001111B,ROW_0;;key row 0, find the col.
       MOV P1,#11111101B      ;;ground row 1
       MOV A,P2 	      ;;read all columns
       ANL A,#00001111B       ;;mask unused bits
       CJNE A,#00001111B,ROW_1;;keyrow 1, find the col.
       MOV P1,#11111011B      ;;ground row 2
       MOV A,P2 	      ;;read all columns
       ANL A,#00001111B       ;;mask unused bits
       CJNE A,#00001111B,ROW_2;;key row 2, find the col.
       MOV P1,#11110111B      ;;ground row 3
       MOV A,P2 	      ;;read all columns
       ANL A,#00001111B       ;;mask unused bits
       CJNE A,#00001111B,ROW_3;;keyrow 3, find the col.
       LJMP K2		      ;;if none, false input, repeat
ROW_0: MOV DPTR,#KCODE0       ;;set DPTR=start of row 0
       SJMP FIND	      ;;find col. key belongs to
ROW_1: MOV DPTR,#KCODE1       ;;set DPTR=start of row 1
       SJMP FIND	      ;;find col. key belongs to
ROW_2: MOV DPTR,#KCODE2       ;;set DPTR=start of row 2
       SJMP FIND	      ;;find col. key belongs to
ROW_3: MOV DPTR,#KCODE3       ;;set DPTR=start of row 3
FIND:  RRC A		      ;;see if any CY bit low
       JNC MATCH	      ;;if zero, get the ASCII code
       INC DPTR 	      ;;point to next col. address
       SJMP FIND	      ;;keep searching
MATCH: CLR A		      ;;set A=0 (match is found)
       MOVC A,@A+DPTR	      ;;get ASCII code from table
       MOV  P0,A	      ;;display pressed key
       LJMP  K1
TIME:  MOV TMOD,#01
       MOV TL0,#0FEH
       MOV TH0,#0B7H
       RET
DELAY: SETB TR0
AGAIN: JNB TF0,AGAIN
       CLR TR0
       CLR TF0
       RET

;;ASCII LOOK-UP TABLE FOR EACH ROW
ORG 0x3000
KCODE0: DB 'A','9','8','7'     ;;ROW 0
KCODE1: DB 'B','6','5','4'     ;;ROW 1
KCODE2: DB 'C','3','2','1'     ;;ROW 2
KCODE3: DB 'D','#','0','*'     ;;ROW 3

END
 

:1000000075A0FF759000E5A0550FB40FF6117111A2
:100010007BE5A0540FB40F0280F31171117BE5A0B2
:10002000540FB40F0280E67590FEE5A0540FB40F94
:10003000217590FDE5A0540FB40F1C7590FBE5A051
:10004000540FB40F177590F7E5A0540FB40F1202B8
:10005000000D903000800D903004800890300880B2
:100060000390300C135003A380FAE493F580020050
:1000700003758901758AFE758CB722D28C308DFD8F
:05008000C28CC28D22BC
:103000004139383742363534433332314423302A5C
:00000001FF



List of 5 messages in thread
TopicAuthorDate
Help for 4X4 matrix keypad interface            01/01/70 00:00      
   What assembler are you using?            01/01/70 00:00      
      it would be impossible to identify the e            01/01/70 00:00      
   What's the last address?            01/01/70 00:00      
   Compiles & Lined OK with CAS.EXE            01/01/70 00:00      

Back to Subject List