c51超長時間延時程序1小時到1000...小時
;;///////////////////////////////////////////////////////////;;
;;[匯編原創(chuàng)]c51超長時間延時程序1小時到1000...小時。
;;19:44 2007-3-10;;
;;6MHZ晶振為100ms;若晶振為12mhz時則50ms;進(jìn)入一次定時中斷;;
;;你用定時中斷0方式1,進(jìn)一次中斷,中斷內(nèi)加1如:inc 40h;
;;RUN COMMAND;;執(zhí)行命令;;
;;///////////////////////////////////////////////////////////;;
ORG 0000H
AJMP MAIN
ORG 000BH
AJMP ET0_0
RETI
ORG 0030H
MAIN:
MOV SP,#10H
MOV TMOD,#01H
MOV IE,#82H
MOV TH0,#(65536-50000)/256
MOV TL0,#(65536-50000)MOD 256
MOV TCON,#10H
MOV 40H,#00H;;毫秒
MOV 41H,#00H;;秒
MOV 42H,#00H;;分
MOV 43H,#00H;;時
MOV 44H,#00H;;日
;;..
LOOP:
NOP
MOV A,40H
CJNE A,#10,TIME1;;10*100ms=1000ms=1s
MOV 40H,#00H
;;RUN COMMAND;;
INC 41H
MOV A,41H
CJNE A,#60,TIME1;;60*1s=1分鐘
MOV 41H,#00H
MOV 40H,#00H
;;RUN COMMAND;;
INC 42H
MOV A,42H
CJNE A,#60,TIME1;;60*1MIN=60分鐘=1小時;;
MOV 42H,#00H
MOV 41H,#00H
MOV 40H,#00H
;;RUN COMMAND;;
INC 43H
MOV A,43H
CJNE A,#24,TIME1;;24*1小時=1天
MOV 43H,#00H
MOV 42H,#00H
MOV 41H,#00H
MOV 40H,#00H
;;RUN COMMAND;;執(zhí)行命令;;
INC 44H
MOV A,44H
CJNE A,#30,TIME1;;1天*30=1個月;;
MOV 44H,#00H
MOV 43H,#00H
MOV 42H,#00H
MOV 41H,#00H
MOV 40H,#00H
;;RUN COMMAND;;
TIME1:
MOV PCON,#01H
AJMP LOOP
ET0_0:
NOP
INC 40H
MOV TH0,#(65536-50000)/256;;
MOV TL0,#(65536-50000)MOD 256
RETI
END