時鐘+秒表+流水燈的單片機匯編程序
//HJSMSY-V1.0單片機開發(fā)板測試程序 //--------------------------------------------- // <<電腦鐘>> //---------------------------------------------
//=======主函數(shù)================================== ORG 0000H LJMP MAIN ORG 000BH LJMP T00 // ORG 001BH // LJMP T11 ORG 0030H //=======程序初始化============================= MAIN: MOV TMOD,#11H MOV TH0,#3CH MOV TL0,#0B0H MOV TH1,#0F0H MOV TL1,#0B0H SETB EA SETB ET0 //SETB ET1 SETB TR0 //SETB TR1 CLR P3.4 MOV R7,#00H ;秒值 MOV 30H,#00H ;秒個位值 MOV 31H,#00H ;秒十位值 MOV 32H,#00H ;分個位 MOV 33H,#00H ;分十位 MOV 34H,#00H ;時個位 MOV 35H,#00H ;時十位 MOV 44H,#00H ;秒表毫秒十位 MOV 45H,#00H ;秒表秒毫秒百位 MOV 46H,#00H ;秒表秒個位 MOV 47H,#00H ;秒表秒十位 MOV 48H,#00H ;秒表分個位 MOV 49H,#00H ;秒表分十位 MOV P2,#0F0H ;P2口按鍵初始化 MOV 40H,#01H ;數(shù)碼管休眠值/流水燈/秒表開關(guān)數(shù) MOV 41H,#08H ;流水燈循環(huán)值 MOV 42H,#00H ;秒表暫停 // ACALL T11
//----------------------------------------------- MAIN1: MOV P0,#0FFH MOV P1,#0FFH MOV R0,40H CJNE R0,#01H,ACL1 ACALL MAIN2 ;時鐘顯示 ACL1:CJNE R0,#02H,ACL2 ACALL MAIN3 ;秒表 ACL2:CJNE R0,#03H,ACL3 ACALL LED ;流水燈 ACL3:ACALL KEY ;按鍵掃描 //ACALL BAO ;定時報警 LJMP MAIN1
//=======報警子程序============================ BAO:MOV R4,33H CJNE R4,#03H,YY1 CLR P3.2 ACALL KEY LJMP YY2 YY1:CJNE R4,#05H,YY2 SETB P3.2 ACALL KEY YY2:RET
//======時鐘掃描子程序======================= MAIN2: MOV A,30H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.0 ACALL DELAY MOV A,31H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.1 SETB P1.0 ACALL DELAY MOV A,32H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.2 SETB P1.1 ACALL DELAY MOV A,33H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.3 SETB P1.2 ACALL DELAY MOV A,34H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.4 SETB P1.3 ACALL DELAY MOV A,35H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.5 SETB P1.4 ACALL DELAY MOV P0,#7FH MOV P1,#0EBH ACALL DELAY MOV P1,#0FFH RET
//========秒表掃描子程序========================= MAIN3: MOV A,44H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.0 ACALL DELAY MOV A,45H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.1 SETB P1.0 ACALL DELAY MOV A,46H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.2 SETB P1.1 ACALL DELAY MOV A,47H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.3 SETB P1.2 ACALL DELAY MOV A,48H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.4 SETB P1.3 ACALL DELAY MOV A,49H MOV DPTR,#TAB MOVC A,@A+DPTR MOV P0,A CLR P1.5 SETB P1.4 ACALL DELAY MOV P0,#7FH MOV P1,#0EBH ACALL DELAY MOV P1,#0FFH RET
//=======定時器T0中斷服務======================== T00:MOV TH0,#0D8H MOV TL0,#0F0H INC R7 CJNE R7,#64H,AA MOV R7,#00H //-------時鐘跑值-------------------------------- TK1:INC 30H;每秒鐘秒個位增一 MOV R6,30H CJNE R6,#0AH,AA MOV 30H,#00H TK2:INC 31H MOV R6,31H CJNE R6,#06H,AA MOV 31H,#00H TK3:INC 32H MOV R6,32H CJNE R6,#0AH,AA MOV 32H,#00H TK4:INC 33H MOV R6,33H CJNE R6,#06H,AA
提交
超越傳統(tǒng)直覺,MATLAB/Simulink助力重型機械的智能化轉(zhuǎn)型
新大陸自動識別精彩亮相2024華南國際工業(yè)博覽會
派拓網(wǎng)絡被Forrester評為XDR領(lǐng)域領(lǐng)導者
智能工控,存儲強基 | ??低晭砭手黝}演講
展會|Lubeworks路博流體供料系統(tǒng)精彩亮相AMTS展會