【正文】
CRESET 長(zhǎng)春理工大學(xué)畢業(yè)設(shè)計(jì) 第 四 章 系統(tǒng)軟件主要設(shè)計(jì)流程 綜述 軟件系統(tǒng)在本設(shè)計(jì)中尤其重要,基本功能大部分是由軟件完成的,發(fā)揮功能的關(guān)鍵控制部分同樣需要軟件的密切配合才能順利實(shí)現(xiàn)。 為了產(chǎn)生手彈的節(jié)奏感,在某些音符 (例如兩個(gè)相同音符)音插入一個(gè)時(shí)間單位的頻率略有不同的音符。 LCD1602 的引腳圖如下, VSS1VDD2VL3RS4R/W5E6D07D18D29D310D411D512D613D714BLA15BLK16 引腳功能如下 : BLA :背光源正極,接 +5V ; BLK :背光源負(fù)極,接地; VO :液晶顯示偏壓信號(hào),通過(guò)電位器 W1 調(diào)節(jié), 1602 偏壓接近 0V ; RS :接 ,決定傳輸類型是數(shù)據(jù)或命令, 1 表示數(shù)據(jù), 0 表示命令; R / W :接 ,讀/寫(xiě)控制, 1 一表示讀, O 一表示寫(xiě); E :接 ,使能端,高電平有效; DB0 ~ DB7: 數(shù)據(jù)端口 ,連接 PA 1602 無(wú)法顯示漢字,農(nóng)歷的日期就不好顯示了。在多字節(jié)方式中讀或?qū)懚际菑牡刂?0的第 0位開(kāi)始。 時(shí)序圖如下: DS1302 的寄存器 DS1302 有 12 個(gè)寄存器,其中有 7 個(gè)寄存器與日歷、時(shí)鐘相關(guān),存放的數(shù)據(jù)位為 BCD 碼形式 ,其日歷、時(shí)間寄存器及其控制字見(jiàn)表 1 表一 DS1302 的時(shí)鐘,日歷寄存器及控制字 寄存器名 命令字 取值范圍 各位內(nèi)容 寫(xiě)操作 讀操作 7 6 5 4 3 2 1 0 秒寄存器 80H 81H 0059 CH 10SEC SEC 分鐘寄存器 82H 83H 0059 0 10MIN MIN 小時(shí)寄存器 84H 85H 0012 或 0023 12/24 1 10/AP HR HR 日期寄存器 86H 87H 0128, 0 10DATE DATE 長(zhǎng)春理工大學(xué)畢業(yè)設(shè)計(jì) 15 月份寄存器 88H 89H 0112 0 0 10M MONTH 周月寄存器 8AH 8BH 0107 0 0 0 0 DAY 年份寄存器 8CH 8DH 0099 10 YEAR YEAR 表中 12或 24小時(shí)的方式選擇位,當(dāng)為 1時(shí),選擇 12小時(shí)。上電運(yùn)行時(shí),在 Vcc≥ 之前, RST 必須保持低電平。 DS1302 由 Vcc1 或 Vcc2 兩者中的較大者供電。不使用 ADC時(shí),該引腳應(yīng)直接與VCC連接 .使用 ADC時(shí)應(yīng)通過(guò)一個(gè)低通濾波器與 VCC連接。在復(fù)位過(guò)程中,即使系統(tǒng)時(shí)鐘還未起振,端口 C 處于高阻狀態(tài)。在復(fù)位過(guò)程中,即使系統(tǒng)時(shí)鐘還未起振,端口 A 處于高阻狀態(tài)。 上電復(fù)位以及可編程的掉電檢測(cè) 不能顯示漢字,顯示信息量有限,若在此題目中應(yīng)用就會(huì)受到很大限制。 方案二:由單片機(jī)實(shí)現(xiàn)時(shí)鐘功能 單片機(jī)內(nèi)部具有定時(shí)器,可方便實(shí)現(xiàn)定時(shí)功能,通過(guò)計(jì)算可知,是定時(shí)器沒(méi) 25ms產(chǎn)生一次中斷,當(dāng)產(chǎn)生 40 次中斷后秒單元將加一,以此類推,從而實(shí)現(xiàn)時(shí),分,秒的走時(shí),并加以顯示 .但由于系統(tǒng)晶振誤差,溫漂,中斷響應(yīng)時(shí)間的不確定性及定時(shí)器重新裝載時(shí)間常數(shù)所帶來(lái)的誤差,決定它不能用來(lái)作為時(shí)鐘的時(shí)基中斷 。 萬(wàn)年歷的不斷更新,為我們生活帶來(lái)極大的方便。本設(shè)計(jì)硬件電路簡(jiǎn)單,難點(diǎn)在于軟件編程中的公農(nóng)歷轉(zhuǎn)換,設(shè)計(jì)完成后經(jīng)測(cè)試基本實(shí)現(xiàn)了上述的功能 關(guān)鍵詞 : Mega16 萬(wàn)年歷 公農(nóng)歷轉(zhuǎn)換 液晶 Abstract Along with the technical and quick development in electronics, appear with the largescale integrated circuit especially, give mankind the life brought the changes of the root. The coal gas reports to the police the system publishes, scribing the electronics measure the instrument walked into the arithmetic figure turns the ages ts function is strong, the function is wellfound, technique forerunner, will quickly technical development in science. In the paper, it introduces a design of digital Calendar based on design made Mega16 as the core controller, the peripheral circuits, including liquid crystal display module, clock module, the keyboard module and alarm module. Software with C language programming , achieves all functions of design. This calendar will not only show the number of points, the second, year, month, day, and have the following functions: display Chinese, the alarm time set, alarm clock, music selection, the whole point of time and free to adjust the time after power outages. The design of hardware circuits is simple, difficult in the Chinese public conversion, the design has been tested after the pletion of the basic functions to achieve the abovementioned Key words: Mega16, Calendar, Lunar conversion of public, LCD 長(zhǎng)春理工大學(xué)畢業(yè)設(shè)計(jì) 5 目錄 目錄 .......................................................................................................................................1 第一章 緒論 ..........................................................................................................................6 研究目的和意義 .........................................................................................................6 國(guó)內(nèi)外研究現(xiàn)狀 ........................................................................................................6 本設(shè)計(jì)研究的內(nèi)容 .....................................................................................................6 第二章 系統(tǒng)整體設(shè)計(jì)方案 ....................................................................................................8 系統(tǒng)功能分析 ...........................................................................................................8 系統(tǒng)方案論證 ...........................................................................................................8 時(shí)鐘模塊 .........................................................................................................8 鍵盤模塊 ..........................................................................................................8 顯示模塊 .........................................................................................................9 第三章 系統(tǒng)硬件設(shè)計(jì) ......................................................................................................... 10 Mega16 單片機(jī)電路設(shè)計(jì) ........................................................................................ 10 Mega16 的介紹 ...................................................................................................... 10 Mega16 的引腳圖及引腳說(shuō)明 .......................................................................... 11 時(shí)鐘接口電路 ......................................................................................................... 13 簡(jiǎn)介 .............................................................................................................. 13 引腳介紹及其功能 ......................................................................................... 13 的控制字節(jié) ......................................................................................... 14 DS1302 的寄存器 ............................................................................................ 14 數(shù)據(jù)輸入輸出 ..................................................................