【正文】
這種計算機就是把智能賦予各種機械的單片機(亦稱微控制器)。概括的講:一塊芯片就成了一臺計算機。 }while(K4==1)。 } //對時檢查函數 void check() { if(AH==hour) { if(AM==min) BZ(30)。} disp(hour,min,sec)。K2function()。 while(ms) { for(i=0。 P1=H%10。 IE=0X82。 24 附錄一 源程序 // 電子時鐘設計 // include define uchar unsigned char define uint unsigned int define SPK P2_1 define K1 P2_2 define K2 P2_3 define K3 P2_4 define K4 P2_5 define LED P2_0 define FLAG P0_0 void keyscan()。不過,通過放慢掃描顯示的頻率,可以看到略顯閃爍的結果,證明軟硬件的仿真成功。在保證安裝無誤后 ,用替換方法排除錯誤。發(fā)生部分由蜂鳴器、電源、 9018 三極管、限流電阻組成。電路中將四個按鍵的一端接公共地,而單片機的 P2 口默認為高電平,一旦按鍵被按下,則該按鍵對應的額管腳被拉低,通過軟件掃描按鍵即可知道用戶所要實現的功能,調用相應的按鍵子程序來完成該操作。 LE:鎖定控制端,當 LE=0 時,允許譯碼輸出。為了保證一定的亮度,實驗表明:在驅動電流取 30 mA 的情況下,每位顯示時間不能小于 1 ms。 5 FLASH存儲器編程時,該引腳加上 +12V 的編程允許電源 Vpp,當然這必須是該器件是使用 12V 編程電壓 Vpp。作為輸入使用時,被外部拉低的引腳由于內部電阻的原因,將輸 4 出電流( IIL)。 在 flash 編程時, P0口也用來接收指令字節(jié);在程序校驗時,輸出指令字節(jié)。硬件設計的主要要求是在保證系統性能的前提下 ,最大限度的降低系統的整體成本 ,同時還要留出以 后功能擴展接口。 C51語言作為高級語言 C語言的移植,易于理解和操作,且結構化較高,本設計即采用 C51 語言作為編程語言,流程比較清晰。 采取的主要技術路線方 法 本設計采取單片機 STC89S5 按鍵開關 與 7 段數碼顯示管顯示模塊 相結合實現不同多種功能 , 此外還有一些簡單的輔助電路,例如屏燈電路及 上電復位及手動復位電路,這些簡單的輔助電路加上單片機及按鍵開關,顯示系統 共同構成了整個硬件設計, 8段數碼管是通過單片機的控制來實現顯示信息的,通過網上固定的 顯示編碼 ,隨時間的變化,要顯示的時間變量隨之變化,通過顯示程序實時調用顯示數組中與之對應的編碼實現實時顯示 ,最后與程序一同燒進單片機,在上電復位等相關的輔助電路下,從而完成整個設計。 單片機以其強大的功能成為多功能電子時鐘的首選,為電子時鐘的功能擴展提供了強大的支持,實現一物多用,提高電子時鐘的使用價值。空閑模式下, CPU 停止工作,允許 RAM、定時器 /計數器、串口、中斷繼續(xù)工 作。作為輸入使用時,被外部拉低的引腳由于內部電阻的原因,將輸出電流( IIL)。 如有必要,可通過對特殊功能寄存器( SFR)區(qū)中的 8EH 單元的 D0 位置位,可禁止 ALE 操作。 LED顯示器有靜態(tài)顯示和動態(tài)顯示兩種方式。 表 22 12864的接口說明 管腳號 管腳 電平 說明 1 c H 數碼管 c位 2 dp H 數碼管 dp位 3 e H 數碼管 e位 。 晶振電路模塊負責給單片機提供時鐘周期。 圖 323 單片機的晶振電路 石英晶體也連接在晶振引腳的輸入和輸出之間 , 等效為一個并聯諧振回路 , 振蕩頻率應該是石英晶體的并聯諧振頻率 。 ( 2) 選擇 file 菜單下的 open design..選項,找到所需的元器件,按照電路圖連接后并保存。應該利用軟件編程的方法來實現。 [4] 何立民 . MCS51 單片機應用系統設計 [M]. 北京:北京航空航天大學出版社, 1991年,第一版, P30。 uchar Msec=0,Asec=0。sec=0。 P1=S/10。i++) { SPK=~SPK。hour++。AM++。 } do{disp(Asec,Msec,0)。 31 } } //END 32 附錄二 軟件仿真圖 33 附錄三 英文文獻及翻譯 英文文獻原文 Singlechip brief introduction The monolithic integrated circuit said that the monolithic micro controller, it is not pletes some logical function the chip, but integrates a puter system to a chip on. Summary speaking: A chip has bee a puter. Its volume is small, the quality is light, the price cheap, for the study, the application and the development has provided the convenient condition. At the same time, the study use monolithic integrated circuit is understands the puter principle and the structure best choice. The monolithic integrated circuit interior also uses with the puter func tion similar module, for instance CPU, memory, parallel main line, but also has with the hard disk behave identically the memory ponent, what is different is its these part performance is opposite our homeuse puter weak many, but the price is also low, generally does not surpass 10 Yuan then ......Made some control electric appliance one kind with it is not the very plex work foot. We use now the pletely automatic drum washer, the platoon petticoat pipe, VCD and so on inside the electrical appliances may see its form! ......It is mainly takes the control section the core part. It is one kind of online like realtime control puter, online like is the scene control, needs to have the strong antijamming ability, the low cost, this is also and the offline type puter (for instance home use PC) main difference. The monolithic integrated circuit is depending on the procedure, and may revise. Realizes the different function through the different procedure, particularly special unique some functions, this is other ponent needs to take the very big effort to be able to achieve, some are the flowered big strength is also very difficult to achieve. One is not the very plex function, if develops in the 50s with the US 74 series, or the 60s39。一個可視化高級語言編寫的小程序里面即使只有一個按鈕,也會達到幾十 K 的尺寸!對于家用 PC 的硬盤來講沒什么,可是對于單片機來講是不能接受的。究其原因,可能就卡在產品未使用單片機或其它可編程邏輯器件上。通過不同的程序實現不同的功能,尤其是特殊的獨特的一些功能,這是別的器件需要費很大力氣才能做到的,有些則是花大力氣也很難做到的。 disp(hour,min,sec)。} if(Asec99) Asec=0。disp(AH,AM,0)。} } 28 //按鍵功能函數 void K1function() { TR0=0。 while(k) { for(i=0。P3=0xfB。deda=0。 uchar AH=0,AM=0,ON=0。 [2] 張毅剛 . MCS51 單片機應用設計 [M]. 哈爾濱:哈爾濱工業(yè)大學出版社, 1997 年,第二版, P69。 51 系列單片機的信號線大體分為讀、寫信號線、片選信號線、時鐘信號線、外部程序存貯器讀選通信號( PSEN)、地址鎖存信號( ALE)、復位信號等幾大類。 圖 41 主程序流程圖 按鍵功能子程序 流程圖, 如 圖 42所示 。上電后,保持 RST 一段高電平時間 。 具體連接如下圖:(電源與地未標出) 11 3 硬件 設計 硬件主要組成部分 設計原理圖 , 如圖 31 所示 。 17 RET L 復位信號,低電平有效。顯然,要顯示某字形就應使此字形的相應字形點亮,實際就是送一個用不同電平組合代表的數據至數碼管。要注意的是:每當訪問外部數據存儲器時將跳過一個 ALE 脈沖。 引腳號第二功能 : T2(定時器 /計數器 T2 的外部計數輸入),時鐘輸出 T2EX(定時器 /計數器 T2 的捕捉 /重載觸發(fā)信號和方向控制) MOSI(在系統編程用) MISO(在系統編程用) SCK(在系統編程用) P2 口: P2 口是一個具有內部上拉電阻的 8 位雙向 I/O 口, P2 輸出緩沖器能驅動 4 個 TTL 邏輯電平。 STC89S52 具有以下標準功能: 8k 字節(jié) Flash, 256 字節(jié) RAM, 32 位 I/O 口線,看門狗定時器, 2 個數據 指針,三個 16 位 定時器 /計數器,一個 6向量 2 級中斷結構,全雙工串行口, 片內晶振及時鐘電路。 參考文獻 ................................................................... 23 附錄一 源程序 .............................................................. 24 附錄二 軟件仿真圖 .................................................