MCS-51定时器,串行口和中断初始化程序
扫描二维码
随时随地手机看文章
程序框图
电路
程序
0030758160 CHK00:MOVSP,#60H
00331204A5 LCALLLEDP
0036900081 MOVDPTR,#CLOCK
0039A882 MOVR0,DPL
003BA983 MOVR1,DPH
003D90000B MOVDPTR,#000BH
00407402 MOVA,#02H
0042F0 MOVX@DPTR,A
0043A3 INCDPTR
0044E9 MOVA,R1
0045F0 MOVX@DPTR,A
0046A3 INCDPTR
0047E8 MOVA,R0
0048F0 MOVX@DPTR,A
0049120DF0 CHK0:LCALL LCK0 ;键扫,显示子程序
004C120068 LCALL PTDS0 ;显示缓冲区放数子程序
004F758901 MOVTMOD,#01H
005243A882 ORLIE,#82H
0055758AB7 MOVTL0,#0B7H
0058758C3C MOVTH0,#3CH;定时中断初始化
005B752300 MOV23H,#00H
005ED28C SETBTR0 ;开定时
0060120425 LOO5:LCALL DIS ;显示
0063120068 LCALL PTDS0
006680F8 SJMPLOO5
00687879 PTDS0:MOVR0,#79H
006AE522 MOVA,22H
006C1177 ACALL PTDS
006EE521 MOVA,21H
00701177 ACALL PTDS
0072E520 MOVA,20H
00741177 ACALL PTDS
007622 RET
0077F9 PTDS:MOVR1,A ;拆送显示缓冲区
0078117C ACALL PTDS1
007AE9 MOVA,R1
007BC4 SWAPA
007C540F PTDS1:ANLA,#0FH
007EF6 MOV@R0,A
007F08 INCR0
008022 RET
0081758AB7 CLOCK:MOVTL0,#0B7H
0084758C3C MOVTH0,#3CH ;恢复初值
0087C0D0 PUSHPSW
0089C0E0 PUSHACC
008BD2D3 SETB0D3H ;保护
008D0523 INC23H ;0.1秒加1
008FE523 MOVA,23H
0091B40A27 CJNEA,#0AH,DONE ;1秒到吗?
0094752300 MOV23H,#00H ;清0.1秒单元
0097E522 MOVA,22H
0099 04 INC A ;秒加1