【正文】
論文分類號: 學校代碼: 13681 畢業(yè)設計說明書 (論文 ) 題目: 基于單片機的電子音樂盒 學生 姓名 : 黨陸登 學號: 2411134 系部 : 信工七系 專業(yè) 班級 : 電氣 111 班 指導教師: 胡敏 二〇 一五 年月 HAOJING COLLEGESHAANXI UNIVERSITY OFSCIENCE& TECHNOLOGY I Electronic music box based on MCU ABSTRACT The ease of use and versatility make SCM widely used in variousmicrocontrol system. This paper introduces a SCMbased electronic music box design, which is based on AT89C2051 single chip microputer as control core, supplemented by some peripheral elements, using assembly language programming to realize music playing functions. Utilizing the residuary port P1 on the SCM, it extends the function of this music box, which could make LED lattice shift display. The electric circuit construction of the whole system is simple, the function has high reliability and the experiment test results satisfy the request. This paper emphasize introduces the design principle of the system, hardware design and software programming ideas. Key words:SCM,AT89C2051,music box,LED shift display II 基于單片機的電子音樂盒 摘 要 單片機的易用性與多功能性使它廣泛應用于各種微控制系統(tǒng)。本文介紹了一種基于單片機的電子音樂盒的設計,它是以 AT89C2051 單片機為控制核心,輔以一些外圍器件,采用匯編語言編寫程序,實現(xiàn)音樂播放功能。并在音樂盒基礎上利用單片機閑置 P1 口拓展了 LED 點陣移位顯示功能。整個系統(tǒng)電路結構簡單,可靠性能高,測試結果滿足設計要求。本文著重介紹了該系統(tǒng)的設計原理,硬件設計方法與軟件編程思路。 關鍵字 :單片機、 AT89C205音樂盒、 LED 移位顯示 III 目 錄 第 1 章 前 言 ............................................................................................................................ 1 單片機介紹 ........................................................................................................ 1 單片機音樂 ........................................................................................................ 2 第 2 章 設計要求及理論基礎 ................................................................................................. 3 設計要求 ............................................................................................................ 3 基本要求 ................................................................................................. 3 創(chuàng)新部分 ................................................................................................. 3 成果形式 ................................................................................................. 3 相關音樂知識 .................................................................................................... 3 單片機產(chǎn)生音頻脈沖原理 ................................................................................ 4 音符頻率 ................................................................................................. 4 定時 /計數(shù)器 0 產(chǎn)生音符頻率 ............................................................... 5 單片機實現(xiàn)音樂的節(jié)拍 .................................................................................... 6 音頻功放 ............................................................................................................ 7 小結 .................................................................................................................... 7 第 3 章 硬件設計 ...................................................................................................................... 8 方案選取 ............................................................................................................ 8 單片機的選取 ......................................................................................... 8 音頻放大電路的選擇 ............................................................................. 9 中斷方式 ............................................................................................... 11 LED 顯示方式 ....................................................................................... 11 LED 驅動電路 ....................................................................................... 12 硬件電路的實現(xiàn) .............................................................................................. 12 AT89C2051 單片機硬件結構 ............................................................... 12 時鐘與復位電路 ................................................................................... 16 選擇按鍵輸入電路 ............................................................................... 17 音頻發(fā)生器 ........................................................................................... 18 音頻放大器 ........................................................................................... 18 小結 .................................................................................................................. 26 第 4 章 軟件設計 .................................................................................................................... 27 LED 移位顯示程序 .......................................................................................... 27 IV 音樂盒功能程序 .............................................................................................. 32 小結 .................................................................................................................. 35 第 5 章 軟硬件調(diào)試 ............................................................................................................... 36 硬件調(diào)試 .......................................................................................................... 36 軟件調(diào)試 .......................................................................................................... 36 性能 測試 .......................................................................................................... 37 LED 顯示畫面 ....................................................................................... 37 單片機輸出樂曲音頻圖 ...................................................................... 37 可靠性分析 ........................................................................................... 38 小結 ................................