本書以89C51單片機為典型機,詳細介紹了MCS-51系列單片機的構(gòu)成、工作原理、指令系統(tǒng)、匯編語言程序設(shè)計、中斷技術(shù)、定時/計數(shù)器、串行口通信等內(nèi)容,并結(jié)合應(yīng)用實際,系統(tǒng)地介紹了MCS-51系列單片機的擴展技術(shù),其中包括存儲器擴展、I/O口擴展、顯示器與鍵盤接口、A/D及D/A接口技術(shù)等。為順應(yīng)單片機技術(shù)的發(fā)展趨勢,跟蹤單片機技術(shù)的*發(fā)展,滿足不同層次的研究開發(fā)人員的需求,本書還詳細介紹了AT89系列單片機及C8051F系列單片機的特點、應(yīng)用和編程開發(fā)方法。本書共分為十一章,內(nèi)容豐富,力求反映當前單片機技術(shù)的*方法,在對單片機原理敘述全面、準確的基礎(chǔ)上,加強了實踐教學(xué)環(huán)節(jié)。為了便于初學(xué)者理解和掌握,本書在內(nèi)容安排上采用循序漸進的論述方法,從基礎(chǔ)理論到實踐應(yīng)用,并充分考慮所使用實例的典型性和實用性,期望讀者在學(xué)習(xí)后,既能掌握單片機的一般原理和接口技術(shù),又能掌握單片機應(yīng)用系統(tǒng)的設(shè)計方法。
自20 世紀80 年代初Intel 公司研制出MCS-51 系列單片機以來,單片機作為最典型的低端嵌入式系統(tǒng),由于其微小的體積和極低的成本,廣泛應(yīng)用于家用電器、機器人、儀器儀表、工業(yè)控制、交通運輸?shù)阮I(lǐng)域。單片機在我國也得到廣泛的推廣和應(yīng)用,成為控制系統(tǒng)中最普遍的應(yīng)用技術(shù)。編者從事過多年的單片機原理與應(yīng)用的教學(xué)工作和單片機應(yīng)用產(chǎn)品的開發(fā)工作,深深體會到當前大部分教學(xué)內(nèi)容與實際應(yīng)用嚴重脫節(jié)。為了使廣大讀者熟悉和掌握MCS-51 系列單片機,作者結(jié)合自己多年的教學(xué)和科研實踐,并參考了大量相關(guān)資料,編寫了本書,力圖從以往教材局限于具體單片機原理的解析上解脫出來,著重于各種功能的應(yīng)用。本書內(nèi)容分為十一章,以MCS-51系列單片機為介紹對象,分別介紹MCS-51 系列單片機結(jié)構(gòu)原理、MCS-51 單片機指令系統(tǒng)、匯編語言程序設(shè)計、并行I/O 口的使用、并行I/O 口的擴展方法及使用、中斷系統(tǒng)和定時/計數(shù)器、A/D 轉(zhuǎn)換接口和D/A 轉(zhuǎn)換接口技術(shù)、鍵盤與顯示器接口技術(shù)等內(nèi)容。近年來,嵌入式微控制器的發(fā)展速度驚人,并融合了許多新的設(shè)計理念和傳統(tǒng)計算機的技術(shù)成果。在目前百花齊放的單片機系列之中,具有系統(tǒng)編程(ISP)特性的片上系統(tǒng)(SoC)系列單片機C8051F 脫穎而出,本書最后介紹了該系列單片機的特點及應(yīng)用,期望對讀者起到拋磚引玉的作用。本書本著理論必需、夠用的原則,突出實用性、操作性,加強理論聯(lián)系實際,語言上通俗易懂,做到了好教易學(xué),以滿足目前教學(xué)的實際需要。本書在編寫過程中,在力求對單片機原理敘述全面、準確的基礎(chǔ)上,加強了實踐教學(xué)環(huán)節(jié)。從工程設(shè)計應(yīng)用的角度出發(fā),列舉了大量的例題和實際操作課題,除提供常見的編程方法和接口電路外,還給出簡單實用的電路。從教學(xué)的實際需要出發(fā),培養(yǎng)學(xué)生的創(chuàng)造性能力、產(chǎn)品開發(fā)能力,力求達到理論與實踐的統(tǒng)一。本書由桑勝舉、王太雷主編,張秀紅、趙曉寧、沈丁、吳月英副主編。參與本書編寫的有:山東科技大學(xué)張琴(第1 章)、山東泰山職業(yè)技術(shù)學(xué)院趙曉寧(第2 章)、泰山學(xué)院吳月英(第3章、第11 章)、張秀紅(第4 章、第8 章)、沈丁(第10 章)、錢藝(第5 章)、欒云才(第6 章)、宗棟(第7 章)、張巖(第9 章)。泰山學(xué)院楊德運、趙繼超、郇正良、葉長國、李芳、周京偉、貝依林等教師參與了部分章節(jié)的編寫工作,書中所有圖表由吳月英精心繪制,全書由桑勝舉進行統(tǒng)稿。
本書得到山東省教育廳教學(xué)改革研究項目(應(yīng)用型本科計算機硬件基礎(chǔ)課程體系的改革與實踐研究,魯教高函2015-12)、山東省泰安市科技發(fā)展專項計劃項目(環(huán)境探測球形機器人科研平臺的構(gòu)建,201320629)、山東省泰安市科技發(fā)展計劃項目(基于C 型臂手術(shù)導(dǎo)航關(guān)鍵技術(shù)及空間姿態(tài)探測儀的研究,2016GX0004)和泰山學(xué)院科技計劃項目(球形機器人驅(qū)動原理及仿真研究,Y-0102013010)的資助。
在此表示衷心的感謝!由于時間倉促,作者水平有限,書中難免存在錯誤和不妥之處,敬請廣大讀者批評指正。
桑勝舉,男,泰山學(xué)院副教授,曾獲泰山學(xué)院優(yōu)秀科研成果一二三等獎各一次,任中國圖學(xué)學(xué)會高級會員,山東省科協(xié)國家級科技思想庫決策專家,山東省計算機學(xué)會理事,泰安市科技咨詢協(xié)會常務(wù)理事。
目 錄
第1 章緒論 ··········································· (1)
1.1 單片機技術(shù)的發(fā)展背景·················· (1)
1.2 單片機的組成······························ (2)
1.3 單片機的特點及應(yīng)用····················· (3)
1.3.1 單片機的特點···················· (3)
1.3.2 單片機的應(yīng)用···················· (4)
1.4 單片機的發(fā)展歷史························ (4)
1.5 單片機分類································· (5)
1.5.1 按單片機功能分類·············· (5)
1.5.2 MCS-51 系列單片機············ (6)
1.6 單片機發(fā)展趨勢··························· (7)
本章小結(jié) ·········································(10)
習(xí)題 1 ·············································(10)
第 2 章單片機的結(jié)構(gòu)及原理·····················(11)
2.1 80C51 單片機的基本結(jié)構(gòu)··············(11)
2.1.1 80C51 單片機的組成··········(11)
2.1.2 80C51 單片機的存儲器·······(13)
2.2 并行I/O 口································(18)
2.2.1 P0 口······························(19)
2.2.2 P1 口······························(20)
2.2.3 P2 口······························(20)
2.2.4 P3 口······························(21)
2.3 時鐘電路與復(fù)位電路····················(21)
2.3.1 時鐘電路與時序················(21)
2.3.2 復(fù)位電路·························(23)
2.4 單片機的工作方式·······················(25)
2.4.1 復(fù)位方式·························(25)
2.4.2 程序執(zhí)行方式···················(25)
2.4.3 節(jié)電工作方式···················(25)
2.4.4 編程和校驗方式················(26)
2.5 單片機的工作過程·······················(27)
2.6 AT89 系列單片機簡介··················(27)
本章小結(jié) ·········································(29)
習(xí)題 2 ·············································(29)
第 3 章單片機的指令系統(tǒng)························(30)
3.1 指令系統(tǒng)簡介·····························(30)
3.2 尋址方式···································(31)
3.3 數(shù)據(jù)傳送類指令··························(35)
3.3.1 內(nèi)部RAM 傳送指令···········(36)
3.3.2 外部RAM 傳送指令···········(37)
3.3.3 數(shù)據(jù)交換類指令················(38)
3.3.4 查表指令·························(38)
3.3.5 堆棧操作指令···················(39)
3.4 算術(shù)運算類指令·························(40)
3.4.1 加法指令·························(40)
3.4.2 減法指令·························(43)
3.4.3 乘法指令·························(43)
3.4.4 除法指令·························(44)
3.5 邏輯運算類指令·························(44)
3.5.1 基本邏輯操作···················(44)
3.5.2 其他邏輯操作···················(46)
3.6 控制轉(zhuǎn)移類指令·························(47)
3.6.1 無條件轉(zhuǎn)移指令················(47)
3.6.2 條件轉(zhuǎn)移指令···················(50)
3.6.3 調(diào)用及返回指令················(51)
3.6.4 空操作指令······················(52)
3.7 位操作類指令····························(53)
3.7.1 位傳送指令······················(53)
3.7.2 位修改指令······················(53)
3.7.3 位邏輯操作指令················(53)
3.7.4 位判斷轉(zhuǎn)移類指令·············(54)
本章小結(jié) ·········································(55)
習(xí)題 3·············································(55)
第 4 章 80C51 匯編語言程序設(shè)計··············(57)
4.1 概述········································(57)
4.1.1 程序設(shè)計語言···················(57)
4.1.2 匯編語言偽指令················(57)
4.1.3 程序匯編方法···················(60)
4.2 順序程序設(shè)計····························(62)
4.3 分支程序設(shè)計····························(64)
4.3.1 一般分支結(jié)構(gòu)程序·············(65)
4.3.2 散轉(zhuǎn)程序設(shè)計···················(68)
4.4 循環(huán)程序設(shè)計····························(70)
4.4.1 循環(huán)程序結(jié)構(gòu)···················(70)
4.4.2 循環(huán)程序?qū)嵗?middot;··················(71)
4.5 查表程序設(shè)計····························(76)
·VI·
4.6 子程序設(shè)計與堆棧技術(shù)················(77)
4.6.1 子程序?qū)嵗?middot;·····················(78)
4.6.2 堆棧結(jié)構(gòu)·························(81)
4.6.3 子程序結(jié)構(gòu)······················(82)
4.6.4 代碼轉(zhuǎn)換程序···················(83)
4.6.5 算術(shù)運算子程序················(85)
4.6.6 查找、排序程序················(89)
本章小結(jié) ·········································(92)
習(xí)題 4 ·············································(92)
第 5 章中斷系統(tǒng)····································(97)
5.1 中斷系統(tǒng)概述····························(97)
5.1.1 中斷的概念······················(97)
5.1.2 中斷的特點······················(97)
5.1.3 中斷系統(tǒng)的功能················(98)
5.2 中斷源與中斷寄存器···················(99)
5.2.1 中斷源····························(99)
5.2.2 中斷寄存器···················· (100)
5.3 中斷處理過程·························· (102)
5.3.1 中斷響應(yīng)······················· (102)
5.3.2 中斷處理······················· (103)
5.3.3 中斷返回······················· (104)
5.3.4 中斷響應(yīng)時間················· (104)
5.4 中斷觸發(fā)方式·························· (104)
5.5 中斷源的擴展·························· (105)
5.5.1 定時器擴展中斷源··········· (105)
5.5.2 中斷查詢擴展················· (106)
5.6 中斷請求的撤除······················· (107)
5.6.1 撤除定時器中斷·············· (107)
5.6.2 撤除串行口中斷·············· (107)
5.6.3 撤除外部中斷················· (107)
5.7 中斷初始化····························· (108)
5.8 應(yīng)用舉例···················