最新回复
ORG 0000H
MOV R0,#70H
MOV A,#6
MOV R2,#8
LOOP2: MOV @R0,A
DEC A
INC R0
DJNZ R2,LOOP2
lcall display
main: lcall key
ljmp main
KEY: ORL P1,#00111100B
MOV A,P1
ORL A,#11000011B
CPL A
JZ NO_KEY
LCALL DELAY
MOV A,P1
ORL A,#11000011B
CPL A
JZ NO_KEY
N_KEY1: JNB Acc.2,N_KEY2
LCALL KEY1F;1#键
LJMP NO_KEY
N_KEY2: JNB Acc.3,N_KEY3
LCALL KEY2F;2#键
LJMP NO_KEY
N_KEY3: JNB Acc.4,N_KEY4
LCALL KEY3F
LJMP NO_KEY
N_KEY4: JNB Acc.5,NO_KEY
LCALL KEY4F
NO_KEY:
ret
KEY1F:
inc 70h
MOV a,70H
cjne a,#10, n70h10
mov 70h,#0
n70h10:
LCALL DISPlaY; 编1键的程序
lcall you_KEY
RET
KEY2F:
inc 71h
MOV a,71H
cjne a,#10, n71h10
mov 71h,#0
n71h10:
LCALL DISPlaY;
lcall you_KEY
RET
KEY3F:
inc 72h
MOV a,72H
cjne a,#10, n72h10
mov 72h,#0
n72h10:
LCALL DISPlaY;
lcall you_KEY
RET
KEY4F:
inc 73h
MOV a,73H
cjne a,#10, n73h10
mov 73h,#0
n73h10:
LCALL DISPlaY;
lcall you_KEY
RET
DELAY: mov r6,#10h
MOV R5 ,#0
DJNZ R5,$
djnz r6,$-4
ret
DISPlay: MOV R3,#6
clr p3.7
MOV R0,#70H
LOOP1: MOV A,@R0
MOV DPTR,#LEDCODE
MOVC A,@A+DPTR
MOV R2,#8
LOOP: RRC A
MOV P1.7,C
CLR P1.6
SETB P1.6
DJNZ R2,LOOP
INC R0
DJNZ R3,LOOP1
SETB P3.7
clr p3.7
ret
you_KEY:MOV A,P1
ORL A,#11000011B
CPL A
JnZ you_KEY
lcall delay
MOV A,P1
ORL A,#11000011B
CPL A
JnZ you_KEY
ret
LEDCODE:db 0d7h,12h,5dh,5bh,9ah,0cbh,0cfh,13h,0dfh,0dbh
END
详情
回复
发表于 2009-5-3 09:17
| |
|
|
此帖出自单片机论坛
赞赏 | ||
|
||
EEWorld Datasheet 技术支持