本文引用地址:http://m.butianyuan.cn/article/201611/323576.htm;================================================================LedPort Equ P2SegPort Equ P0Timer1 Equ 0FB23HSec400Chg Bit 30HSec10Chg Bit 31HSecChg Bit 32HMinChg Bit 33HSec400 Data 34HSec10 Data 35HSecond Data 36HTemp Data 37HRelieve Data 38HTemp1 Data 39H;================================================================Org 0000HAjmp Main;================================================================InitSysT: Mov Relieve,#50Mov TMod,#00100000BMov TL1,#Low(Timer1)Mov TH1,#High(Timer1)Setb EASetb ET1Setb TR1Mov Sec400,#40Mov Sec10,#10Mov Second,#60Clr Sec400ChgClr Sec10ChgClr SecChgClr MinChgRet;================================================================Org 001BHMov TL1,#Low(Timer1)Mov TH1,#High(TImer1)AJmp CTC1EntryCTC1Entry: Setb Sec400ChgDjnz Sec400,T1IntOutMov Sec400,#40Setb Sec10ChgInc Sec10HEXDjnz Sec10,T1IntOutMov Sec10,#10Setb SecChgDjnz Second,T1IntOutMov Second,#60Setb MinChgT1IntOut: RetI ;================================================================Delay: Mov R6,#40Delay1: Mov R7,#0Delay2: Djnz R7,Delay2Djnz R6,Delay1Ret;================================================================ SegDisplay: Mov Dptr,#TableSegLoop: Movc A,@A+DptrMov SegPort,ARet;----------------------------------------------------------------Table: DB 11000000BDB 11111001BDB 10100100BDB 10110000BDB 10011001BDB 10010010BDB 10000010BDB 11011000BDB 10000000BDB 10010000B;================================================================Main: MOv Temp1,#11111110BMov Temp,#0Acall InitSysTMainLoop0: Jbc Sec400Chg,DoSec400MainLoop1: Jbc Sec10Chg,DoSec10MainLoop2: Jbc SecChg,DoSecondMainLoop3: Jbc MinChg,DoMinuteAjmp MainLoop0DoSec400:Sjmp MainLoop1DoSec10:Mov A,TempAcall SegDisplayDjnz Relieve,L3Mov Relieve,#50Inc TempMov A,TempCjne A,#9,MainLoop2Mov Temp,#0 L3: Sjmp MainLoop2DoSecond: Mov LedPort,Temp1Mov A,Temp1Rl AMov Temp1,ASjmp MainLoop3DoMinute:Sjmp MainLoop0 ;================================================================End
評論