本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本人初学单片机
写了这套程序,请大家拍砖
现在问题是:设定时间1602根本不响应
本程序主要是:P1口与1602。D0-D7连接P3.7P3.6P3.5分别和E RW RW连接
开关是独立式中断方式的按钮,P2.0-P2.5分别代表 秒+1,分+1,时+1,复位,开始倒计时,停止倒计时
现在附上程序和ISIS仿真图(仿真图是测试P2.0按键的响应)
ORG 0000H
LJMP START
ORG 0003H
LJMP KEY
ORG 000BH
LJMP TIME0
ORG 0030H
TAB1:DB 'ZHOUXUAN06212087'
TAB2:DB'0123456789'
RS EQU P3.7
RW EQU P3.6
E EQU P3.5
MOV P1,#01H
ACALL ENABLE
START: MOV P1,#38H
ACALL ENABLE
MOV P1,#06H
ACALL ENABLE
MOV P1,#0CH
ACALL ENABLE
MOV 20H,#00H
MOV 21H,#00H
MOV 22H,#00H
MOV 23H,#00H
MOV 24H,#00H
MOV 25H,#00H
MOV 26H,#00H
SETB EA
SETB ET0
MOV TMOD,#11H
MOV TL0,#0B0H
MOV TH0,#3CH
MOV R2,#02H
MOV R1,#0C6H
YCL:MOV P1,R1
LCALL ENABLE
MOV A,#3AH
LCALL WRITE2
MOV R1,#0C9H
DJNZ R2,YCL
MOV R2,#10H
MOV R1,#80H
MOV R5,#00H
YCL2:MOV P1,R1
LCALL ENABLE
MOV DPTR,#TAB1
MOV A,R5
MOVC A,@A+DPTR
LCALL WRITE2
INC R1
INC R5
DJNZ R2,YCL2
LOOP: LCALL DIS
KEY:
PUSH PSW
PUSH ACC
LCALL DL10MS
MOV A,P2
CPL A
CJNE A,#00H,LOOP
GG: MOV IE,#00H
CPL A
CJNE A,#0FEH,L00P002
LJMP KEY1
L00P002: CJNE A,#0FDH,L00P003
LJMP KEY2
L00P003: CJNE A,#0FBH,L00P004
LJMP KEY3
L00P004: CJNE A,#0F7H,L00P005
LJMP KEY4
L00P005: CJNE A,#0EFH,L00P006
LJMP KEY5
L00P006: CJNE A,#0DFH,EXIT
LJMP KEY6
EXIT:POP ACC
POP PSW
RETI
KEY1:
INC 25H
MOV A,25H
CJNE A,#10,LOOP
MOV 25H,#0
INC 24H
MOV A,24H
CJNE A,#6,LOOP
MOV 24H,#0
SJMP LOOP
KEY2:
INC 23H
MOV A,23H
CJNE A,#10,LOOP
MOV 23H,#0
INC 22H
MOV A,22H
CJNE A,#6,LOOP
MOV 22H,#0
SJMP LOOP
KEY3:
INC 21H
MOV A,21H
CJNE A,#10,LOOP
MOV 21H,#0
INC 20H
LJMP LOOP
KEY4:
MOV 20H,#00H
MOV 21H,#00H
MOV 22H,#00H
MOV 23H,#00H
MOV 24H,#00H
MOV 25H,#00H
MOV 26H,#00H
LJMP LOOP
KEY5: MOV IE,#82H
SETB TR0
LJMP LOOP
KEY6:CLR TRO
MOV IE,#00H
POP ACC
POP PSW
RETI
DIS:
MOV DPTR,#TAB2
MOV R3,#02H
MOV R0,#0C4H
MOV A,20H
XSXS: MOV P1,R0
ACALL ENABLE
MOVC A,@A+DPTR
LCALL WRITE2
INC R0
MOV A,21H
DJNZ R3,XSXS
MOV R3,#02H
MOV R0,#0C7H
MOV A,22H
FZXS: MOV P1,R0
ACALL ENABLE
MOVC A,@A+DPTR
LCALL WRITE2
INC R0
MOV A,23H
DJNZ R3,FZXS
MOV R3,#02H
MOV R0,#0CAH
MOV A,24H
MZXS: MOV P1,R0
ACALL ENABLE
MOVC A,@A+DPTR
LCALL WRITE2
INC R0
MOV A,25H
DJNZ R3,MZXS
RET
WRITE2:
MOV P1,A
SETB RS
CLR RW
CLR E
CALL DELAY
SETB E
RET
ENABLE:
CLR RS
CLR RW
CLR E
ACALL DELAY
SETB E
RET
DELAY:
MOV R7,#25
D1: MOV R6,#255
D2: DJNZ R6,$
DJNZ R7,D1
RET
TIME0: PUSH ACC
PUSH PSW
MOV TH0,#3CH
MOV TL0,#0B0H
CLR P0.1
INC 26H
MOV A,26H
CJNE A,#20,EXIT2
SETB P0.1
MOV 26H,#00H
EXIT2:LJMP RETURN
MOV A ,25H
CJNE A,#00,X1
SJMP X2
X1:DEC 25H
MOV A,25H
CJNE A,#00,RETURN
X2:MOV A,24H
CJNE A,#00,X3
SJMP X4
X3:DEC 24H
MOV 25H,#09H
SJMP RETURN
X4:MOV A,23H
CJNE A,#00,Y1
SJMP Y2
Y1:DEC 23H
MOV 24H,#05H
MOV 25H,#09H
SJMP RETURN
Y2:MOV A,22H
CJNE A,#00,Y3
SJMP Y4
Y3:DEC 22H
MOV 23H,#09H
MOV 24H,#05H
MOV 25H,#09H
SJMP RETURN
Y4:MOV A,21H
CJNE A,#00,Z1
SJMP Z2
Z1:DEC 21H
MOV 22H,#05H
MOV 23H,#09H
MOV 24H,#05H
MOV 25H,#09H
SJMP RETURN
Z2:MOV A,20H
CJNE A,#00,Z3
LJMP OVER
Z3:DEC 20H
MOV 21H,#09H
MOV 22H,#05H
MOV 23H,#09H
MOV 24H,#05H
MOV 25H,#09H
SJMP RETURN
OVER:LJMP LOOP
RETURN: POP PSW
POP ACC
RETI
DL10MS:MOV R7,#10H
DLP1:MOV R6,#0FAH
DLP2:NOP
NOP
DJNZ R6,DLP2
DJNZ R7,DLP1
RET
END
TEST2.rar
(12.83 KB, 下载次数: 3)
|
|