已经解决了。。。
发送端
ORG 0000H
JMP START
ORG 0100H
START:
ACALL INIT
MAIN:
MOV P2,#0F0H
MOV A,P2
XRL A,#0F0H
JZ MAIN
ACALL KEYSCAN
MOV A,30H
MOV DPTR,#TABLE2
MOVC A,@A+DPTR
MOV R2,A
CJNE A,#79H,SHOW
MOV A,#0C0H
MOV P1,A
ACALL ENABLE
MOV P1,R2
SETB P0.5
CLR P0.4
CLR P0.3
ACALL DELAY2
SETB P0.3
ACALL DELAY
ALOOP1:
MOV 40H,R2
MOV SBUF,#0E1H
JNB TI,$;·¢ËíÖD¶Ï
CLR TI
JNB RI,$;½óêÕÖD¶Ï
CLR RI
MOV A,SBUF;¶toÅ»úó|′eDÅoÅ
XRL A,#0E2H;òì»òÅD¶¨êÇ·ñ×¼±¸íê±Ï£¨ÅD¶Ï·¢ËíÏûÏ¢êÇ·ñÎa#0E2£©
JNZ ALOOP1;¿aê¼·¢Ëíêy¾Y걶¨òå3õê¼μØÖ·,Õa¸öμØÖ·àïÃæ′æ′¢òa·¢ËíμÄêy¾Y
MOV R0,#40H
MOV R6,#00H;D£Ñéoí
ALOOP2:
MOV SBUF,@R0
MOV A,R6
ADD A,@R0
MOV R6,A
JNB TI,$
CLR TI
MOV SBUF,R6
JNB TI,$;·¢ËíÖD¶Ï
CLR TI
JNB RI,$;½óêÕó|′eÖD¶Ï
CLR RI
MOV A,SBUF
XRL A,#00H
JNZ ALOOP2
JMP MAIN
SHOW:
MOV P1,A
SETB P0.5
CLR P0.4
CLR P0.3
ACALL DELAY2
SETB P0.3
ACALL DELAY
JMP ALOOP1
INIT:
MOV A,#00000001B
MOV P1,A
ACALL ENABLE
MOV A,#00111000B
MOV P1,A
ACALL ENABLE
MOV A,#00001111B
MOV P1,A
ACALL ENABLE
MOV A,#00000110B
MOV P1,A
ACALL ENABLE
MOV A,#00H
MOV P1,A
ACALL ENABLE
CLR EA
MOV TMOD,#20H
MOV TH1,#0F4H
MOV TL1,#0F4H
MOV PCON,#00H
SETB TR1
MOV SCON,#50H
KEYSCAN:MOV P2,#0F0H;Ïè¶ááDÔù¶áDD
MOV A,P2
ANL A,#0F0H
MOV R3,A
MOV P2,#0FH
MOV A,P2
ANL A,#0FH
ORL A,R3
CJNE A,#0FFH,KEYPRO;¼ì2a¼üÖμêÇ·ñ3é1|¶áèë
RET
KEYPRO: MOV R3,A
MOV DPTR,#KEYVALUE
MOV R4,#0FFH;′æ¼üÖμ±íμ½¼üÂë±íμÄÆ«òÆá¿
KEY1: INC R4 ;é¨Ãè¼üÂë±íàïÃæμÄêyÖμ
MOV A,R4
MOVC A,@A+DPTR
CJNE A,03H,KEY1
MOV A,R4
MOV 30H,A
DELAY1: MOV R6,#60H;Ñóê±3ìDò
DE2: MOV R7,#90H
DJNZ R7,$
DJNZ R6,DE2
RET
ENABLE: CLR P0.5;D′Ãüáî
CLR P0.4
CLR P0.3
ACALL DELAY2
SETB P0.3
RET
DELAY2: MOV P1,#0FFH
CLR P0.5
SETB P0.4
CLR P0.3
NOP
SETB P0.3
JB P1.7,DELAY2
RET
DELAY:
MOV R5,#10H;Ñóê±3ìDò
D1:
MOV R6,#30H
D2:
MOV R7,#90H
DJNZ R7,$
DJNZ R6,D2
DJNZ R5,D1
RET
KEYVALUE:DB 0E7H,0D7H,0B7H,077H,0EBH,0DBH,0BBH,07BH,0EDH,0DDH,0BDH,07DH,0EEH,0DEH,0BEH,07EH;¼üÂë¾ØÕó
TABLE2: DB 30H,31H,33H,38H,64H,69H,61H,6EH,6BH,65H,79H,74H,67H,3CH,5FH,3EH
END
接收端
ORG 0000H
JMP START
ORG 0100H
START:
ACALL INIT
JMP BLOOP1
BLOOP1:
JNB RI,$
CLR RI
MOV A,SBUF
XRL A,#0E1H
JNZ BLOOP1
MOV SBUF,#0E2H
JNB TI,$
CLR TI
MOV R0,#40H
MOV R6,#00H
BLOOP2:
JNB RI,$
CLR RI
MOV A,SBUF
MOV @R0,A
ADD A,R6
MOV R6,A
JNB RI,$
CLR RI
MOV A,SBUF
XRL A,R6
JZ END1
MOV SBUF,#0FFH
JNB TI,$
CLR TI
SJMP BLOOP1
END1:
MOV SBUF,#00H
JNB TI,$
CLR TI
CJNE @R0,#79H,SHOW
MOV A,#0C0H
MOV P2,A
ACALL ENABLE
MOV P2,@R0
SETB RS
CLR RW
CLR E
ACALL DELAY
SETB E
ACALL DELAY1
JMP BLOOP1
SHOW:
MOV P2,@R0
SETB P1.4
CLR P1.3
CLR P1.2
ACALL DELAY
SETB P1.2
ACALL DELAY1
JMP BLOOP1
INIT:
RS EQU P1.4
RW EQU P1.3
E EQU P1.2
MOV P2,#00000001B
ACALL ENABLE
MOV P2,#00111000B
ACALL ENABLE
MOV P2,#00001111B
ACALL ENABLE
MOV P2,#00000110B
ACALL ENABLE
MOV P2,#00H
ACALL ENABLE
CLR EA
MOV TMOD,#20H
MOV TH1,#0F4H
MOV TL1,#0F4H
MOV PCON,#00H
SETB TR1
MOV SCON ,#50H
RET
ENABLE: CLR RS
CLR RW
CLR E
ACALL DELAY
SETB E
RET
DELAY: MOV P2,#0FFH
CLR RS
SETB RW
CLR E
NOP
SETB E
JB P2.7,DELAY
RET
DELAY1:
MOV R5,#10H;Ñóê±3ìDò
D1:
MOV R6,#30H
D2:
MOV R7,#90H
DJNZ R7,$
DJNZ R6,D2
DJNZ R5,D1
RET
END
|