超強(qiáng)多功能電子鐘程序 作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對面交流海量資料庫查詢 收藏 ;************************;秒表存儲功能;************************SAVETIME: MOV R4,3AHMOV A, 3BHCJNE A,#0AH,SAVEMIDRETSAVEMID: INC R4MOV 3AH,R4MOV 3BH,R4CJNE R4,#01H,SAVE1MOV R0,#80HLJMP SAVE10SAVE1: CJNE R4,#02H,SAVE2MOV R0,#88HLJMP SAVE10SAVE2: CJNE R4,#03H,SAVE3MOV R0,#90HLJMP SAVE10SAVE3: CJNE R4,#04H,SAVE4MOV R0,#98HLJMP SAVE10SAVE4: CJNE R4,#05H,SAVE5MOV R0,#0A0HLJMP SAVE10SAVE5: CJNE R4,#06H,SAVE6MOV R0,#0A8HLJMP SAVE10SAVE6: CJNE R4,#07H,SAVE7MOV R0,#0B0HLJMP SAVE10SAVE7: CJNE R4,#08H,SAVE8MOV R0,#0B8HLJMP SAVE10SAVE8: CJNE R4,#09H,SAVE9MOV R0,#0C0HLJMP SAVE10SAVE9: CJNE R4,#0AH,SAVE10MOV R0,#0C8HSAVE10: MOV @R0,40HINC R0MOV @R0,41HINC R0MOV @R0,42HINC R0MOV @R0,43HINC R0MOV @R0,44HINC R0MOV @R0,45HINC R0MOV @R0,46HINC R0MOV @R0,47HRET;****************************;蜂鳴器程序,查詢是否全部為0;***************************BUZZER: PUSH ACCPUSH BPUSH PSWMOV R4,#00HMOV R6,#7FHBUZZTURN: MOV A,#8HADD A,R6MOV R0,AMOV R6,AMOV A,@R0 CJNE A,NUMBER_H2,BUZZER_1DEC R0MOV A,@R0 CJNE A,NUMBER_G2,BUZZER_1DEC R0MOV A,@R0 CJNE A,NUMBER_F2,BUZZER_1DEC R0MOV A,@R0 CJNE A,NUMBER_E2,BUZZER_1DEC R0MOV A,@R0 CJNE A,NUMBER_D2,BUZZER_1DEC R0MOV A,@R0 CJNE A,NUMBER_C2,BUZZER_1DEC R0MOV A,@R0 CJNE A,NUMBER_B2,BUZZER_1DEC R0MOV A,@R0 CJNE A,NUMBER_A2,BUZZER_1 MOV 3AH,R4CLR BUZZMOV 39H,#1BUZZER_1: INC R4CJNE R4,#0AH,BUZZTURNBUZZER_2:MOV A,NUMBER_A ;時十位CJNE A,#0H,RETURN3MOV A,NUMBER_B ;時個位CJNE A,#0H,RETURN3MOV A,NUMBER_C ;分十位CJNE A,#0H,RETURN3MOV A,NUMBER_D ;分個位CJNE A,#0H,RETURN3MOV A,NUMBER_E ;秒十位CJNE A,#0H,RETURN3MOV A,NUMBER_F ;秒個位CJNE A,#0H,RETURN3MOV A,NUMBER_G ;秒十分位CJNE A,#0H,RETURN3MOV A,NUMBER_H ;秒百分位CJNE A,#0H,RETURN3CLR BUZZ ;開蜂鳴器CLR TR0 ;關(guān)計數(shù)器0CLR EX0 ;關(guān)外部中斷0 MOV 39H,#0 CLR P3.7POP PSWPOP BPOP ACCHERE: LJMP MAIN0 RETURN3:POP PSWPOP BPOP ACCRET ;**********************************;整點報時;**********************************RING: PUSH ACCPUSH BPUSH PSWMOV A,NUMBER_C6 ;分十位CJNE A,#0H,RINGOUTMOV A,NUMBER_D6 ;分個位CJNE A,#0H,RINGOUTMOV A,NUMBER_E6 ;秒十位CJNE A,#0H,RINGOUTMOV A,NUMBER_F6 ;秒個位CJNE A,#0H,RINGOUTMOV A,NUMBER_G6 ;秒十分位CJNE A,#0H,RINGOUTMOV A,NUMBER_H6 ;秒百分位CJNE A,#0H,RINGOUTCLR BUZZMOV 3EH, #1RINGOUT: MOV A,3EHCJNE A,#1,RING_OUTMOV A,NUMBER_E6 ;秒十位CJNE A,#1H,RING_OUTSETB BUZZMOV 3EH, #0RING_OUT:POP PSWPOP BPOP ACCRET;**********************************;鬧鐘程序;**********************************ALARMCLOCK:PUSH ACCPUSH BPUSH PSW;SETB 20H.1JNB 20H.1,ALARM_OUT1 ;啟動鬧鐘標(biāo)志位0關(guān),1開MOV R0,#0D0HMOV A,@R0 ;時十位CJNE A,NUMBER_A6,ALARM_OUTMOV R0,#0D1HMOV A,@R0 ;時個位CJNE A,NUMBER_B6,ALARM_OUTMOV R0,#0D2HMOV A,@R0 ;分十位CJNE A,NUMBER_C6,ALARM_OUTMOV R0,#0D3HMOV A,@R0 ;分個位CJNE A,NUMBER_D6,ALARM_OUTMOV R0,#0D4HMOV A,@R0 ;秒十位CJNE A,NUMBER_E6,ALARM_OUTMOV R0,#0D5HMOV A,@R0 ;秒個位CJNE A,NUMBER_F6,ALARM_OUTMOV R0,#0D6HMOV A,@R0 ;秒十分位CJNE A,NUMBER_G6,ALARM_OUTMOV R0,#0D7HMOV A,@R0 ;秒百分位CJNE A,NUMBER_H6,ALARM_OUTCLR BUZZSETB 20H.2ALARM_OUT:JNB 20H.2,ALARM_OUT1 ;關(guān)鬧鐘鈴聲標(biāo)志MOV R0,#0D3H ;分個位MOV A,@R0INC ACJNE A,NUMBER_D6,ALARM_OUT1MOV R0,#0D4HMOV A,@R0 ;秒十位CJNE A,NUMBER_E6,ALARM_OUT1MOV R0,#0D5HMOV A,@R0 ;秒個位CJNE A,NUMBER_F6,ALARM_OUT1MOV R0,#0D6HMOV A,@R0 ;秒十分位CJNE A,NUMBER_G6,ALARM_OUT1MOV R0,#0D7HMOV A,@R0 ;秒百分位CJNE A,NUMBER_H6,ALARM_OUT1SETB BUZZCLR 20H.2 ;關(guān)鬧鐘鈴聲標(biāo)志ALARM_OUT1:POP PSWPOP BPOP ACCRET;**********************************;鬧鐘賦初值程序;**********************************ALARMC: PUSH ACCPUSH BPUSH PSWJB 20H.0,ALARMCOUT ;判斷是否可以改變定時的時間,0可以,1不可以MOV R2,#09HMOV R1,#0D0HSETB 20H.0 ;判斷是否可以改變定時的時間,0可以,1不可以ALARMCOUT:POP PSWPOP BPOP ACCRET;**********************************;更改鬧鐘時間程序;**********************************ACKCHANGE:PUSH ACCPUSH BPUSH PSWMOV R2,#09HMOV R1,#0D0HMOV R0,#0D0HBACK_2: MOV @R0,#0AH ;D0~D8是存儲鬧鐘空間,只能在初始化時清0INC R0CJNE R0,#0D8H,BACK_2;CLR 20H.0POP PSWPOP BPOP ACCRET;**********************************;啟動/關(guān)閉鬧鐘;**********************************ACKSTART: PUSH ACCPUSH BPUSH PSWMOV A,4BH ; RL A MOV 4BH,AJNB ACC.1,ACK_OUT ;查詢,A最低位為0時暫停計時,為1繼續(xù)計時SETB 20H.1 ;啟動鬧鐘標(biāo)志位0關(guān),1開SETB P3.4LJMP ACKOUTACK_OUT: CLR 20H.1 ;啟動鬧鐘標(biāo)志位0關(guān),1開CLR P3.4ACKOUT: POP PSWPOP BPOP ACCRET;**********************************;顯示程序;**********************************DISPLAY: PUSH ACCPUSH BPUSH PSWMOV R3,#0FEHMOV A,39HCJNE A,#5,YU_0MOV R0,#37HLJMP DISPLAY_AYU_0: CJNE A,#1,YU_1MOV R4,3AHINC R4CJNE R4,#01H,SAVE_1MOV R0,#87HLJMP DISPLAY_ASAVE_1: CJNE R4,#02H,SAVE_2MOV R0,#8FHLJMP DISPLAY_ASAVE_2: CJNE R4,#03H,SAVE_3MOV R0,#97HLJMP DISPLAY_ASAVE_3: CJNE R4,#04H,SAVE_4MOV R0,#9FHLJMP DISPLAY_ASAVE_4: CJNE R4,#05H,SAVE_5MOV R0,#0A7HLJMP DISPLAY_ASAVE_5: CJNE R4,#06H,SAVE_6MOV R0,#0AFHLJMP DISPLAY_ASAVE_6: CJNE R4,#07H,SAVE_7MOV R0,#0B7HLJMP DISPLAY_ASAVE_7: CJNE R4,#08H,SAVE_8MOV R0,#0BFHLJMP DISPLAY_ASAVE_8: CJNE R4,#09H,SAVE_9MOV R0,#0C7HLJMP DISPLAY_ASAVE_9: CJNE R4,#0AH,YU_1MOV R0,#0CFH ;動態(tài)顯示初始化,使r0指向緩沖區(qū)首地址LJMP DISPLAY_AYU_1: CJNE A,#2,YU_2MOV R0,#0D7HLJMP DISPLAY_AYU_2: CJNE A,#3,YU_3MOV R0,#0DFHLJMP DISPLAY_AYU_3: CJNE A,#4,YU_4MOV R0,#0EFHLJMP DISPLAY_AYU_4: MOV R0,#47HDISPLAY_A:MOV DPTR,#TABLEMOV A,@R0MOVC A,@A+DPTR MOV P2,R3 MOV P0,A ACALL DELAYDISDEC R0MOV A,R3JNB ACC.7,LD1RL AMOV R3,ALJMP DISPLAY_ALD1: POP PSWPOP BPOP ACCRET; *********************;查表程序;*********************TABLE: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0F7H,0FEH,0BFH,0FFH; 0 1 2 3 4 5 6 7 8 9 A B C DRET DELAYDIS: MOV R7,#250 ;04HDELDIS: DJNZ R7,DELDISRET;************************************;計分器選擇程序A/B;************************************SCOREAB: PUSH ACCPUSH BPUSH PSWMOV A,4CH ; RL A MOV 4CH,AJNB ACC.1,SCO_B ;查詢,調(diào)整分?jǐn)?shù)SETB 20H.3SETB P3.1CLR P3.7 ;計分器標(biāo)志位,甲A調(diào)整LJMP SCOOUT SCO_B:CLR 20H.3 ;計分器標(biāo)志位,乙B調(diào)整SETB P3.7CLR P3.1SCOOUT: POP PSWPOP BPOP ACCRET;************************************;計分器分?jǐn)?shù)調(diào)整:加1;************************************SCOREINC: PUSH ACCPUSH BPUSH PSWJNB 20H.3,INCB ;計分器標(biāo)志位,0時乙B調(diào)整MOV R0,#0DAH ;1時甲A乙B調(diào)整LJMP SCOMID_0INCB: MOV R0,#0DFHSCOMID_0: MOV A,@R0INC AMOV @R0,ACJNE A,#0AH,INCAB_0MOV A,#0MOV @R0,ADEC R0MOV A,@R0CJNE A,#0DH,SCOYUMOV A,#0SCOYU: INC AMOV @R0,ACJNE A,#0AH,INCAB_0MOV A,#0MOV @R0,ADEC R0MOV A,@R0CJNE A,#0DH,SCOWEIMOV A,#0SCOWEI: INC AMOV @R0,AINCAB_0: POP PSWPOP BPOP ACCRET;************************************;計分器分?jǐn)?shù)調(diào)整:減1;************************************SCOREDEC: PUSH ACCPUSH BPUSH PSWSETB PSW.3CLR PSW.4JNB 20H.3,DECB ;計分器標(biāo)志位,0時乙B調(diào)整MOV R0,#0DAH ;1時甲A乙B調(diào)整LJMP SCOMID_1DECB: MOV R0,#0DFH ;個位SCOMID_1: MOV A,@R0DEC AMOV @R0,ACJNE A,#0FFH,DECAB_5MOV R1,#0DEHMOV A,@R1CJNE A,#00H,DECABPENGMOV R1,#0DDHMOV A,@R1CJNE A,#0DH,DECAB_1MOV A,#0MOV @R0,ALJMP DECAB_5DECABPENG:CJNE A,#0DH,DECAB_1MOV A,#0MOV @R0,ALJMP DECAB_5LJMP DECAB_2 DECAB_1: MOV A,#9DECAB_2: MOV @R0,ADEC R0 ;十位MOV A,@R0DEC AMOV @R0,ACJNE A,#0FFH,DECAB_6MOV R1,#0DDHMOV A,@R1CJNE A,#00H,DECAB_YUMOV A,#0DHMOV @R0,ALJMP DECAB_5DECAB_6: CJNE A,#00H,DECAB_5MOV R1,#0DDHMOV A,@R1CJNE A,#0DH,DECAB_YUMOV A,#0DHMOV @R0,ALJMP DECAB_5DECAB_YU: CJNE A,#0DH,DECAB_3MOV A,#0DHLJMP DECAB_4DECAB_3: MOV A,#9DECAB_4: MOV @R0,ADEC R0 ;百位MOV A,@R0DEC AMOV @R0,ACJNE A,#00H,DECAB_5MOV A,#0DHMOV @R0,ADECAB_5: CLR PSW.3CLR PSW.4POP PSWPOP BPOP ACCRET 上一頁 1 2 3 下一頁
評論