点此处看清晰电路图
RS EQU P2.0 RW EQU P2.1 E EQU P2.2
ORG 0000H LJMP START ORG 000BH LJMP YANT0 ORG 001BH LJMP SLET1 ORG 0050H
START: MOV R0,#60H MOV R2,#32 CLEARDISP: MOV @R0,#00H INC R0 DJNZ R2,CLEARDISP MOV SP,#2FH MOV 20H,#00H mov r6,#64h mov r7,#14h MOV IE, #8AH MOV TMOD,#11H MOV TL0,#0B0H MOV TH0,#3CH MOV TL1,#0B0H MOV TH1,#3CH MOV 7EH,#18 MOV 7DH,#05H MOV R2,#01H ACALL ENABLE MOV R2,#06H ACALL ENABLE MOV R2,#0CH ACALL ENABLE MOV R2,#38H ACALL ENABLE MOV R2,#01H ACALL ENABLE LCALL process LCALL DISPLAY START1: LCALL TEST MOV 75H,#10 STA1: MOV 76H,#100 STA: LCALL keyset LCALL process LCALL DISPLAY DJNZ 76H,STA DJNZ 75H,STA1 SJMP START1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;温度采集子程序 ;R3存放采集数据 ;7FH存放结果 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TEST: CLR A MOV R3,A MOV 7FH,A MOV P0,#0FFH MOV R5,#08H LCALL GATHER RET
GATHER: SETB P2.3 NOP NOP CLR P2.3 NOP NOP NOP NOP PWAIT: JB P3.2,RMOVD AJMP PWAIT RMOVD: SETB P3.4 MOV A,P0 ADD A,R3 MOV R3,A CLR P3.4 JNC GAC INC B GAC: DJNZ R5,GATHER MOV R5,#03H
AVER: CLR C XCH A,B RRC A XCH A,B RRC A DJNZ R5,AVER MOV 7FH,A
MOV B,#30H DIV AB MOV 7FH,A MOV A,B CLR C CJNE A,#04H,WD1 WD1: JC OUTG INC 7FH OUTG: RET
;;;;;;;;;;;;;;;;;;;;;;;;;;; ;睡眠子程序 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
SLET1: push acc push psw clr tr1 clr et1 MOV TL1,#0B0H MOV TH1,#3CH djnz r6,outt1 mov r6,#64h MOV A,70H SUBB A,#02H JZ OUTT1 INC 7EH INC 70H MOV A,7EH CJNE A,#30,OUTT1 MOV A,70H CJNE A,#02H,OUTT1 MOV 70H,#02H outt1: pop psw pop acc setb tr1 setb et1 reti
;;;;;;;;;;;;;;;;;;;;;;;;;;; ;延时关机子程序 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
YANT0: push acc push psw clr tr0 clr et0 MOV TL0,#0B0H MOV TH0,#3CH djnz r7,outt0 mov r7,#14h djnz 7Dh, outt0 LCALL process lcall display mov r2,#01h ;清屏 acall enable mov pcon,#02h outt0: pop psw pop acc setb tr0 setb et0 reti
;;;;;;;;;;;;;;;;;;;;;;;;;; ;按键子程序 ;;;;;;;;;;;;;;;;;;;;;;;;;;
keyset: mov a,p2 anl a,#0f0h cjne a,#0f0h,keyl0 ret keyl0: LCALL dl10ms mov a,p2 anl a,#0f0h cjne a,#0f0h,keyl1 ret keyl1: jnb acc.4,k4 ;睡眠 jnb acc.5,k5 ;延时 jnb acc.6,k16 ;> jnb acc.7,k17 ;< ret k16:ljmp k6 k17:ljmp k7
k4: jnb p2.4,keyl1 jb psw.1,k40 setb tr1 setb psw.1 ret k40: mov r2,#01h ;清屏 acall enable clr tr1 clr psw.1 mov r6,#64h MOV 70H,#00H ret ke: ljmp keyl1
k5: jnb p2.5,ke jb f0,k50 setb f0 K51: LCALL process LCALL DISPLAY mov a,p2 anl a,#0f0h cjne a,#0f0h,k511 AJMP K51 K511: LCALL dl10ms mov a,p2 anl a,#0f0h cjne a,#0f0h,K512 AJMP K51 K512: jnb acc.5,k55 ;确定 jnb acc.6,k56 ;> jnb acc.7,k57 ;< sjmp k51 K56: JNB P2.6,K512 CLR C mov a,7DH add a,#05h mov 7DH,a subb a,#35 jnz k51 mov 7DH,#05h ljmp k51 K57: jnb p2.7,k512 CLR C mov a,7DH subb a,#05h mov 7DH,a jnz k51 mov 7DH,#30 sjmp k51 K55: jnb p2.5,k512 setb et0 setb tr0 ljmp start1 k50: mov r2,#01h ;清屏 acall enable clr et0 clr tr0 clr f0 mov r7,#14h mov 7Dh,#05h ret k6: jnb p2.6,lkeyl1 jb psw.1,k61 INC 7EH MOV A,7EH SUBB A,#30 JNZ K61 MOV 7EH,#18 K61: ret
lkeyl1:ljmp keyl1 k7: jnb p2.7,lkeyl1 jb psw.1,k71 dec 7Eh mov a,7Eh SUBB A,#17 JNZ k71 MOV 7EH,#30 k71: ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;数据处理 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
process: MOV R0,#7dh MOV R1,#71H MOV R2,#03H PR1: MOV A,@R0 MOV B,#100 DIV AB MOV A,#10 XCH A,B DIV AB SWAP A MOV @R1,A MOV A,B ORL A,@R1 MOV @R1,A INC R0 INC R1 DJNZ R2,PR1 MOV R0,#71H MOV R1,#77H MOV R2,#03H PR2: mov a,@r0 anl a,#0f0h swap a ADD A,#30H mov @r1,a mov a,@r0 inc r1 anl a,#0fh ADD A,#30H mov @r1,a INC R0 INC R1 DJNZ R2,PR2 ret ;;;;;;;;;;;;;;;;;;;;;;; ;显示子程序 ;;;;;;;;;;;;;;;;;;;;;;;
display:mov r2,#02h ; 清屏 acall enable mov r2,#54h acall able mov r2,#63h acall able mov r2 ,#3ah acall able MOV R2,7BH ACALL ABLE MOV R2,7CH ACALL ABLE mov r2,#87h acall enable mov r2,#54h acall able mov r2,#73h acall able mov r2,#3ah acall able MOV R2,79H ACALL ABLE MOV R2,7AH ACALL ABLE jnb psw.1,psw1 mov r2,#8eh acall enable mov r2,#73h acall able mov r2,#6ch acall able mov r2,#65h acall able mov r2,#65h acall able mov r2,#70h acall able psw1: jnb f0,pswf0 mov r2,#0c0h acall enable mov r2,#74h acall able mov r2,#69h acall able mov r2,#6dh acall able mov r2,#65h acall able mov r2,#0c5h acall enable MOV R2,77H ACALL ABLE mov r2,#0c6h acall enable MOV R2,78H ACALL ABLE pswf0: ret
enable: mov p1,r2 clr rs clr rw clr e acall wait setb e ret wait: mov p1,#0ffh clr rs setb rw wait1: clr e nop setb e jb p1.7,wait1 ret able: mov p1,r2 setb rs clr rw clr e acall wait setb e ret dl1ms:mov r3,#14H dl1: mov r4,#19H dl2: djnz r4,dl2 djnz r3,dl1 ret
dl10ms:mov r3,#200 dl10: mov r4,#19H djnz r4,$ djnz r3,dl10 ret END |