【正文】
INC 38H MOV A,38H CJNE A,18H,$+6 MOV 38H,00H SJMP TIME1HOUR1 TIME1MIN: CLR 05H CLR 06H SETB 03H 。等待鍵釋放 INC 3AH MOV A,3AH CJNE A,3CH,$+6 MOV 3AH,00H SETB 03H SETB 04H SJMP TIME2MIN1 CLR 03H CLR 04H INC 3AH MOV A,3AH CJNE A,3CH,$+6 MOV 3AH,00H SJMP TIME2MIN2 TIME2SIGN: CLR 03H CLR 04H SETB 01H 。等待鍵釋放 INC 3DH MOV A,3DH CJNE A,3CH,$+6 MOV 3DH,00H SETB 03H SETB 04H SJMP TIME3MIN1 。等待鍵釋放 INC 3BH MOV A,3BH CJNE A,18H,$+6 MOV 3BH,00H SETB 05H SETB 06H SJMP TIME2HOUR CLR 05H CLR 06H INC 3BH MOV A,3BH CJNE A,18H,$+6 MOV 3BH,00H SJMP TIME2HOUR1 TIME2MIN: CLR 05H CLR 06H SETB 03H 。等待鍵釋放 RET TIME3SET1: LJMP TIME3SET TIME1SET: SETB 05H 。等待鍵按下 JB ,$9 TIMEHOUR1: LCALL DL02S LCALL KEY JNB ,$+19 。 INTT0: PUSH ACC PUSH PSW CLR ET0 CLR TR0 MOV A,06H 。 實現(xiàn)閃動設(shè)定閃動可選用段碼送00H實現(xiàn),也可禁止當前位顯示,選通位送0實現(xiàn)。 圖52 主程序流程圖 計時子程序模塊的實現(xiàn)當T0中斷時,執(zhí)行本程序,因T0設(shè)為50毫秒中斷,故中斷20次為1秒。此電路用于定時時發(fā)出提示音。圖41 片內(nèi)RAM區(qū) 實驗板電路原理圖實驗板電路結(jié)構(gòu)框圖如圖42所示,原理電路圖如圖43所示。如圖31所示。(2)辦公自動化領(lǐng)域 單片機作為嵌入式系統(tǒng)廣泛應用于現(xiàn)代辦公設(shè)備,如計算機的鍵盤、磁盤驅(qū)動、打印機、復印機、電話機和傳真機等。因此,單片機只需要和適當?shù)能浖巴獠吭O(shè)備相結(jié)合,便可成為一個單片機控制系統(tǒng)。單片機應用的重要意義還在于,它從根本上改變了傳統(tǒng)的控制系統(tǒng)設(shè)計思想和設(shè)計方法。關(guān)鍵詞:單片機;時鐘;定時器;數(shù)碼管Abstract: This design is the clock design based on mcu. The design mainly uses single chip to achieve its function, in this design, we use LED digital display hours,minutes, seconds, to 24 hour time, according to the principle of dynamic display of digital tube to display, use the 12MHz crystal oscillation pulse, the timer count,and a digital circuit implementation of the when, sub, seconds the figures show that the timing device, can display the basic function of time, also can realize the adjustment of the time, the clock of high precision, convenient use,multiple functions, easy integration, based on introducing the development situation of the micro controller, the design and implementation of the function, as well as the experimental board hardware conditions, and the function of each circuit are analyzed. The main work in the software programming, using experimental board to realize the time, date, time and setting of their functions,the software programming and debugging process in detail are described, and the timing error analysis and correction, the timing and tone and display conflict problems and solutions. The experiment proved that the effect is good, can be put into use. Therefore, the design and development of the clock has a good application prospect.Keywords: single chip microputer。大則可以構(gòu)成復雜的工業(yè)過程控制系統(tǒng),完成復雜的控制功能;小則可以用于家電控制,甚至可以用于兒童電子玩具。早期常用的一些時間控制單元都使用模擬電路設(shè)計制作的,其定時準確性和重復精度都不是很理想,現(xiàn)在基本上都是基于數(shù)字技術(shù)的新一代產(chǎn)品,隨著單片機性價比的不斷提高,新一代產(chǎn)品的應用也越來越廣泛。例如,有的芯片以51內(nèi)核為核心,集成了USB控制器、SMART CARD接口、MP3解碼器、CAN或者I*I*C總線控制器等,LED、LCD或VFD顯示驅(qū)動器也開始集成在8位單片機中。(5)智能儀表與集成智能傳感器 目前在各種電氣測量儀表中普遍采用了單片機應用系統(tǒng)來代替?zhèn)鹘y(tǒng)的測量系統(tǒng),使得測量系統(tǒng)具有存儲、數(shù)據(jù)處理、查詢及聯(lián)網(wǎng)等智能功能。當路定時設(shè)置完后按K2鍵保存定時設(shè)定值并返回時間顯示。由于AT89S52具有ISP 的功能,即可以通過并口線直接將程序下載到單片機內(nèi),因此, AT89S52 具有兩種狀態(tài),下載程序狀態(tài)和運行狀態(tài)。單片機軟件的設(shè)計主要包括執(zhí)行軟件(完成各種實質(zhì)性功能)的設(shè)計和監(jiān)控軟件的設(shè)計。圖53 計時子程序流程圖 圖54 顯示子程序流程圖 顯示子程序模塊的實現(xiàn)顯示原理在前面已給予了說明,流程圖如圖54所示。 定時音與顯示相沖突問題及解決方案,頻率1K~2K,~1毫秒,小于6 毫秒,因顯示時每個數(shù)碼管顯示1毫秒,至少需要6毫秒,故蜂鳴器響時無法進行顯示。重裝初值(高8位修正值) SETB TR0 DJNZ R4, $+5 。等待鍵釋放 INC 32H MOV A,32H CJNE A,18H,$+6 MOV 32H,00H SETB 05H SETB 06H SJMP TIMEHOUR CLR 05H CLR 06H INC 32H MOV A,32H CJNE A,18H,$+6 MOV 32H,00H SJMP TIMEHOUR1 TIMEMIN: CLR 05H CLR 06H SETB 03H 。顯示時長 LCALL DL02S LCALL KEY JNB ,$+9 JNB ,TIME3SET1 DJNZ 40H,$12 CLR 0AH LCALL DISPLAY LCALL KEY JNB ,$6 。等待鍵按下 JB ,$9 TIME2HOUR1: LCALL DL02S LCALL KEY JNB ,$+19 。等待鍵按下 JB ,$9 TIME3MIN2: LCALL DL02S LCALL KEY JNB ,$+19 。4位閃爍標志位置位 SETB 04H