智能光电定时器课程设计

NOP

MOV A, P1 ;读入P1 CPL A ;取反 ANL A,#0FH ;高四位 MOV 40H,A ;小时数单元 MOV 4CH,A ;小时数放入 MOV 4AH,#10H

MOV 4BH,#0 ;

LCALL MULTI ;转换成秒数 LOOP: END1: MOV 4DH,R3

MOV 4EH,R4

CPL P3.7 ;选择分 LCALL DELAY20MS MOV A,P1

CPL A ;取反 ANL A,#0FH

MOV 41H,A ;分钟数放入缓冲单单元 MOV 4CH,A ;分钟数放入 MOV 4AH,#58H

MOV 4BH,#0 ;

LCALL MULTI ;转换成秒数 MOV A,4DH ADD A,R3 MOV 4DH,A MOV A,4EH

ADDC A,R4 ;此次结果与

MOV 4EH,A ;送入计数单元4DH为高 SETB TR0 ;启动定时器 AJMP LOOP ;进入循环 ORG 00C0H MOV A,40H MOV 4CH,A MOV 4AH,#10H MOV 4BH,#0EH LCALL MULTI MOV 4DH,R3 MOV 4EH,R4 MOV A,42H MOV 4CH,A MOV 4AH,#58H MOV 4BH,#02H LCALL MULTI MOV A,4DH ADD A,R3

MOV 4DH,A MOV A,4EH ADDC A,R4 MOV 4EH,A MOV A,41H MOV 4CH,A MOV 4AH,#3CH MOV 4BH,#00H LCALL MULTI MOV A,4DH ADD A,R3 MOV 4DH,A MOV A,4EH ADDC A,R4

MOV 4EH,A ;

NOP

RET ;程序进 ;外部中断0中断响应程序

ORG 0110H INT0: PUSH ACC PUSH PSW

LCALL DELAY20MS

JB P3.2,EN ;是误脉冲 CLR 20H.0 ;已经处于 CLR EA ;开中断 LCALL TIP LCALL END1 NOP NOP NOP

ENDINT0: POP PSW POP ACC RETI

LED: LJMP INDICATE ;-------------------------------------------------------------- ;定时器0中断响应子程序

ORG 0140H T0: PUSH PSW PUSH ACC

JB 01H,THAND JB 00H,TPHOTO JB 07H,LED MOV TH0,#0D8H MOV TL0,#0F0H

SETB TR0 INC 47H MOV A,47H

CJNE A,#25,NCHANGE2 CPL P1.7

MOV 47H,#00H NCHANGE2: INC 46H

MOV A,46H

CJNE A,#50,NOHANDLE MOV 46H,#00H MOV A,4DH SUBB A,#01H MOV 4DH,A ORL A,4EH SUBB A,#00H MOV 4EH,A ORL A,4DH NOP NOP NOP

JNZ NOHANDLE SETB 07H LCALL MUSIC

LJMP NOHANDLE TPHOTO: LCALL DELAY20MS INC 42H

WAITTO: JB P3.4, WAITTO LCALL DELAY20MS JB P3.4, WAITTO SETB EA LCALL TIP

MOV TH0,#0FFH MOV TL0,#0FFH LJMP NOHANDLE

THAND: JB 20H.7,I MOV TH0,#0 MOV TL0,#0DFH SETB TR0 INC 47H MOV A,47H

CJNE A,#25,N1 CPL P1.7

MOV 47H,#00H NCHANGE1: INC 46H

判断定时 定时器T0 ;秒针指示 ; ;

MOV A,46H

CJNE A, #50,NOHANDLE MOV 46H,#00H

MOV A,4DH ;计数低位 SUBB A,#01H MOV 4DH,A MOV A,4EH SUBB A, #00H MOV 4EH,A ORL A,4DH NOP NOP NOP

JNZ NOHAN ; SETB 20H.7

LCALL MUSIC ;给出声音 NOHANDLE: POP ACC POP PSW RETI

INDICATE: CPL P1.7 ;指示灯快 INC 43H MOV A,43H

CJNE A,#10,NE ;到0.2秒 CPL P1.7 ;指示灯状 MOV 43H,#00H NOP NOP NOP

LJMP NOHANDLE ;-------------------------------------------------------------- ;外部中断1中断响应程序

ORG 0210H INT1: PUSH PSW PUSH ACC

LCALL DELAY ;软件去抖 JB P3.3,ENDINT1

INC 40H WAITINT1: JNB P3.3,WAITINT1

LCALL DELAY20MS

JNB P3.3,WA ;等待操作

LCALL TIP NOP NOP NOP

;

联系客服:779662525#qq.com(#替换为@)