【正文】
02H,2502H,2402H,2206H,2902H 。在此,我要對要求我們做這次課程設計的余老師致以衷心的感謝,因為余老師給了我一次難得的鍛煉的機會。后來有一段時間,我在課余的時間去旁聽了幾堂韓建民老師的《計算機組成原理》,對計算機的指令系統(tǒng)和尋址方式有了點認識,再回過頭來看單片機的指令系統(tǒng)的時武漢紡織大學 2021 屆畢業(yè)設計論文 26 候覺得慢慢的有頭緒了,不再像原先那樣摸不著頭腦。=== 預存歌曲表 === TABLE2: DW 2202H,2902H,2902H,2902H,2906H,2702H 。送入低字節(jié) MOV TL0,A SETB TR0 DK1A:MOV A,P2 。 圖 29 電子琴發(fā)音電路 供電及復位電路 電子琴的供電電路和復位電路見圖 210。 單片機在 工作時,由內(nèi)部振蕩器產(chǎn)生或由外直接輸入的送至內(nèi)部控制邏輯單元的時鐘信號的周期稱為時鐘周期。 時鐘頻率 024MHz 從時長角度看, 2 的時長為四分音的一半,即為八分音符長; 4 的時長為八分音符的一半,即為十六分音符長; 5 的時長為四分音符的一半,即為八分音符長; 6的時長為四分音符長。以 1ⅰ八音區(qū)為例。故簡易電子樂器的研制具有一定的社會意義。 一般說來,單片機不像其他專業(yè) 樂器那樣能奏出多種音色的聲音,即不包含相應幅度的諧波頻率。 以標準音高 A為例: 標準音高 A 的頻率 f=440Hz,其對應的周期為: usfT 2272/1 ?? ( 11) 因此需要在單片機 I/O 口輸出周期為 T=2272us 的方波脈沖,如圖 11 所示 圖 11單片機控制音調(diào)示意圖 武漢紡織大學 2021 屆畢業(yè)設計論文 3 由上圖可知: 單片機輸出高電平和低電平信號均為: usTt 11362/ ?? ( 12) 也就是說,單片機上定時器的中斷觸發(fā)時間為 1136us。 2 系統(tǒng)的主要硬件電路的設 計 單片機控制系統(tǒng)原理 芯片選用 在本次課程設計中我采用 Atmel 公司的 AT89C52 單片機。 低功耗空閑和掉電模式 時鐘頻率越高,單片機控制器的控制節(jié)拍就越快,運算速度也就越快。屏蔽高四位,高四位為行,低四位為列 XRL A,0FH JZ NOKEY1 。=== 發(fā)聲子程序 === SOUND: SETB SPK 武漢紡織大學 2021 屆畢業(yè)設計論文 23 ACALL SDELAY CLR SPK ACALL SDELAY RET 延時子程序 。 DW 2702H,2502H,2402H,2021H,2208H 。最后,我還要感謝韓建民老師和電子 071 的張琦同學,他們曾多次不厭其煩地為我解答了不少疑惑,使我在對指令系統(tǒng)的理解上少走了不少彎路。我覺得單片機作為微型計算機的一種,必然和計算機有一定的共性。==== 計數(shù)器初值表 == 武漢紡織大學 2021 屆畢業(yè)設計論文 25 TABLE1: DW 64021,64103,64260,64400 DW 64524,64580,64684,64777 DW 64820,64898,64968,65030 DW 65058,65110,65157,65178 預存歌曲表 。送入高字節(jié) MOV TH0,A INC TEMP MOV A,TEMP MOVC A,A+DPTR MOV STL0,A 。 武漢紡織大學 2021 屆畢業(yè)設計論文 11 圖 28 “毛刺”現(xiàn)象 發(fā)音電路 電子琴發(fā)音電路見圖 29。 C1,C2 的典型值為30PF。 3 個 16 位可編程定時 /計數(shù)器中斷 1= G43 的節(jié)拍示意圖,見圖 12 在圖中,總共有三拍: 2 為一拍, 5 為一拍, 6 為一拍。在一個八度音里,有 12 個半音。而一些簡易的電子樂器價格相對便宜,學習上手快,價格相對便宜,一般人容易負擔的起,能夠滿足一般愛好者的需求。單片機演奏的音樂基本都是單音頻率。如果單片機采用定時器工作方式 1,它以振蕩器的十二分頻信號為計數(shù)脈沖。 AT89C52 是美國Atmel 公司生產(chǎn)的低電壓、高性能 CMOS 8 位單片機,片內(nèi)含 8KB 的可反復檫寫的程序存儲器和 12B 的隨機存取數(shù)據(jù)存儲器( RAM),器件采用 Atmel 公司的高密度、非易失性存儲技術(shù)生產(chǎn),兼容標準 MCS51 指令系統(tǒng),片內(nèi)配置通用 8 位中央處理器( CPU)和 Flash 存儲單元,功能強大的 AT89C52 單片機可靈活應用于各種控制領(lǐng)域。 軟件設置睡眠和喚醒功能 簡易電子琴的組成框圖 武漢紡織大學 2021 屆畢業(yè)設計論文 7 圖 22 電子琴系統(tǒng)原理框圖 簡易電子琴的 proteus 總體仿真圖 電子琴的 proteus 總體仿真圖見圖 23。 一般來說單片機內(nèi)部有一個帶反饋的線性反相放大器,外界晶振(或接陶瓷振蕩器)和電容就可組成振蕩器,如圖 24 所示。判斷是否有鍵按下,沒有就跳轉(zhuǎn) LCALL DELY10MS MOV A,P2 。=== 延時子程序 === SDELAY: MOV A,R4 。 DW 0000H 。 參考文獻 [1] 張鑫 ,華臻 ,陳書謙 .單片機原理與應用 .[M].電子工業(yè)出版社, [2] 肖婧 .單片入門與趣味實驗設計 [M].北京航空航天大學出版社, [3] 陳明熒 .8051 單片機課程設計實訓教材 [M].清華大學出版社, [4] 趙建領(lǐng) .51 系列單片機開發(fā)寶典 [M].電子工業(yè)出版社, [5] 求是科技 .8051 系列單片機 C 程序設計完全手冊 [M].人民郵電出版社, [6] 樓然苗 ,李光飛 .51 系列單片機設計實例 [M].北京航空航天大學出版武漢紡織大學 2021 屆畢業(yè)設計論文 27 社 , [7] 侯媛彬等,凌陽單片機原理及其畢業(yè)設計精選 2021 年,科學出版社 [8] 羅亞非,凌陽十六位單片機應用基礎(chǔ) 2021 年 北京航空航天大學出版社 [9] 北京北 陽電子有限公司, 061A 凌陽單片機及其附帶光盤 2021 年 [10]張毅剛等, MCS51 單片機應用設計,哈工大出版社, 2021 年第 2 版 [11]霍孟友等,單片機原理與應用,機械工業(yè)出版社, [12]霍孟友等,單片機原理與應用學習概要及題解,機械工業(yè)出版社, [13]許泳龍等,單片機原理及應用,機械工業(yè)出版社, 外文資料 Description The AT89C51 is a lowpower, highperformance CMOS 8bit microputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmel’s highdensity nonvolatile memory technology and is patible with the industrystandard MCS51 instruction set and pinout. The onchip Flash allows the program memory to be reprogrammed insystem or by a conventional nonvolatile memory programmer. By bining a versatile 8bit CPU 武漢紡織大學 2021 屆畢業(yè)設計論文 28 with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microputer which provides a highlyflexible and costeffective solution to many embedded control applications. Function characteristic The AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16bit timer/counters, a five vector twolevel interrupt architecture, a full duplex serial port, onchip oscillator and clock circuitry. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Powerdown Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset. Pin Description VCC: Supply voltage. GND: Ground. Port 0: Port 0 is an 8bit opendrain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance 0 may also be configured to be the multiplexed loworder address/data bus during accesses to external program and data memory. In this mode P0 has internal 0 also receives the code bytes during Flash programming,and outputs the code bytes during programverification. External pullups are required during programverification. Port 1 Port 1 is an 8bit bidirectional I/O port with internal Port 1 output buffers can sink/source four TTL 1s are written to Port 1 pins they are 武漢紡織大學 2021 屆畢業(yè)設計論文 29 pulled high by the internal pullups and can be used as inputs. As inputs,Port 1 pins that are externally being pulled low will source current (IIL) because of the internal 1 also receives the loworder address bytes during Flash programming and verification. Port 2 Port 2 is an 8bit bidirectional I/O port with internal Port 2 output buffers can sink/source four TTL 1s are written to Port 2 pins they are pulled high by the internal p