【正文】
單片機(jī)的數(shù)據(jù)存儲器由讀寫存儲器RAM組成。其最大容量可擴(kuò)展到64k,用于存儲實時輸入的數(shù)據(jù)。8051內(nèi)部有256個單元的內(nèi)部數(shù)據(jù)存儲器,其中00H~7FH為內(nèi)部隨機(jī)存儲器RAM,80H~FFH為專用寄存器區(qū)。實際使用時應(yīng)首先充分利用內(nèi)部存儲器,從使用角度講,搞清內(nèi)部數(shù)據(jù)存儲器的結(jié)構(gòu)和地址分配是十分重要的。因為將來在學(xué)習(xí)指令系統(tǒng)和程序設(shè)計時會經(jīng)常用到它們。8051內(nèi)部數(shù)據(jù)存儲器地址由00H至FFH共有256個字節(jié)的地址空間,該空間被分為兩部分,其中內(nèi)部數(shù)據(jù)RAM的地址為00H~7FH(即0~127)。而用做特殊功能寄存器的地址為80H~FFH。在此256個字節(jié)中,還開辟有一個所謂“位地址”區(qū),該區(qū)域內(nèi)不但可按字節(jié)尋址,還可按“位(bit)”尋址。對于那些需要進(jìn)行位操作的數(shù)據(jù),可以存放到這個區(qū)域。從00H到1FH安排了四組工作寄存器,每組占用8個RAM字節(jié),記為R0~R7。究竟選用那一組寄存器,由前述標(biāo)志寄存器中的RS1和RS0來選用。在這兩位上放入不同的二進(jìn)制數(shù),即可選用不同的寄存器組,如附表1所示。三、特殊功能寄存器 特殊功能寄存器(SFR)的地址范圍為80H~FFH。在MCS-51中,除程序計數(shù)器PC和四個工作寄存器區(qū)外,其余21個特殊功能寄存器都在這SFR塊中。其中5個是雙字節(jié)寄存器,它們共占用了26個字節(jié)。各特殊功能寄存器的符號和地址見附表2。其中帶*號的可位尋址。特殊功能寄存器反映了8051的狀態(tài),實際上是8051的狀態(tài)字及控制字寄存器。用于CPU PSW便是典型一例。這些特殊功能寄存器大體上分為兩類,一類與芯片的引腳有關(guān),另一類作片內(nèi)功能的控制用。與芯片引腳有關(guān)的特殊功能寄存器是P0~P3,它們實際上是4個八位鎖存器(每個I/O口一個),每個鎖存器附加有相應(yīng)的輸出驅(qū)動器和輸入緩沖器就構(gòu)成了一個并行口。MCS-51共有P0~P3四個這樣的并行口,可提供32根I/O線,每根線都是雙向的,并且大都有第二功能。其余用于芯片控制的寄存器中,累加器A、標(biāo)志寄存器PSW、數(shù)據(jù)指針DPTR等的功能前已提及,而另一些寄存器的功能在后面有關(guān)部分再作進(jìn)一步介紹單片機(jī)的指令系統(tǒng)和尋址方式 單片機(jī)要正常運(yùn)作,事先需編制程序,再把程序放入存貯器中,然后由CPU執(zhí)行該程序。程序是由指令組成的,指令的基本組成是操作碼和操作數(shù)。單片機(jī)的品種很多,設(shè)計時怎樣表示操作碼和操作數(shù),都有各自的規(guī)定,再有指令代碼也各不相同,因此,必須對所選單片機(jī)的全部指令,也就是所謂“指令系統(tǒng)”,有足夠的了解。各個系列的單片機(jī)雖然有不同的指令系統(tǒng),但也有其共同性。掌握一種單片機(jī)的指令系統(tǒng),對其它系列單片機(jī)可以起到觸類旁通的作用。MCS-51單片機(jī)應(yīng)用廣泛,派生品種多,具有代表性,所以,這里以MCS-51系列的指令系統(tǒng)為例說明“指令”的組成和應(yīng)用。單片機(jī)的應(yīng)用 目前單片機(jī)滲透到我們生活的各個領(lǐng)域,幾乎很難找到哪個領(lǐng)域沒有單片機(jī)的蹤跡。導(dǎo)彈的導(dǎo)航裝置,飛機(jī)上各種儀表的控制,計算機(jī)的網(wǎng)絡(luò)通訊與數(shù)據(jù)傳輸,工業(yè)自動化過程的實時控制和數(shù)據(jù)處理,廣泛使用的各種智能IC卡,民用豪華轎車的安全保障系統(tǒng),錄像機(jī)、攝像機(jī)、全自動洗衣機(jī)的控制,以及程控玩具、電子寵物等等,這些都離不開單片機(jī)。更不用說自動控制領(lǐng)域的機(jī)器人、智能儀表、醫(yī)療器械以及各種智能機(jī)械了。因此,單片機(jī)的學(xué)習(xí)、開發(fā)與應(yīng)用將造就一批計算機(jī)應(yīng)用與智能化控制的科學(xué)家、工程師。 單片機(jī)廣泛應(yīng)用于儀器儀表、家用電器、醫(yī)用設(shè)備、航空航天、專用設(shè)備的智能化管理及過程控制等領(lǐng)域,大致可分如下幾個范疇: 單片機(jī)具有體積小、功耗低、控制功能強(qiáng)、擴(kuò)展靈活、微型化和使用方便等優(yōu)點(diǎn),廣泛應(yīng)用于儀器儀表中,結(jié)合不同類型的傳感器,可實現(xiàn)諸如電壓、功率、頻率、濕度、溫度、流量、速度、厚度、角度、長度、硬度、元素、壓力等物理量的測量。采用單片機(jī)控制使得儀器儀表數(shù)字化、智能化、微型化,且功能比起采用電子或數(shù)字電路更加強(qiáng)大。例如精密的測量設(shè)備(功率計,示波器,各種分析儀)。 用單片機(jī)可以構(gòu)成形式多樣的控制系統(tǒng)、數(shù)據(jù)采集系統(tǒng)。例如工廠流水線的智能化管 芯片理,電梯智能化控制、各種報警系統(tǒng),與計算機(jī)聯(lián)網(wǎng)構(gòu)成二級控制系統(tǒng)等。 可以這樣說,現(xiàn)在的家用電器基本上都采用了單片機(jī)控制,從電飯煲、洗衣機(jī)、電冰箱、空調(diào)機(jī)、彩電、其他音響視頻器材、再到電子秤量設(shè)備,五花八門,無所不在。 現(xiàn)代的單片機(jī)普遍具備通信接口,可以很方便地與計算機(jī)進(jìn)行數(shù)據(jù)通信,為在計算機(jī)網(wǎng)絡(luò)和通信設(shè)備間的應(yīng)用提供了極好的物質(zhì)條件,現(xiàn)在的通信設(shè)備基本上都實現(xiàn)了單片機(jī)智能控制,從手機(jī),電話機(jī)、小型程控交換機(jī)、樓宇自動通信呼叫系統(tǒng)、列車無線通信、再到日常工作中隨處可見的移動電話,集群移動通信,無線電對講機(jī)等。 單片機(jī)在醫(yī)用設(shè)備中的用途亦相當(dāng)廣泛,例如醫(yī)用呼吸機(jī),各種分析儀,監(jiān)護(hù)儀,超聲診斷設(shè)備及病床呼叫系統(tǒng)等等。 某些專用單片機(jī)設(shè)計用于實現(xiàn)特定功能,從而在各種電路中進(jìn)行模塊化應(yīng)用,而不要求使用人員了解其內(nèi)部結(jié)構(gòu)。如音樂集成單片機(jī),看似簡單的功能,微縮在純電子芯片中(有別于磁帶機(jī)的原理),就需要復(fù)雜的類似于計算機(jī)的原理。如:音樂信號以數(shù)字的形式存于存儲器中(類似于ROM),由微控制器讀出,轉(zhuǎn)化為模擬音樂電信號(類似于聲卡)。 在大型電路中,這種模塊化應(yīng)用極大地縮小了體積,簡化了電路,降低了損壞、錯誤率,也方便于更換。 單片機(jī)在汽車電子中的應(yīng)用非常廣泛,例如汽車中的發(fā)動機(jī)控制器,基于CAN總線的汽車發(fā)動機(jī)智能電子控制器,GPS導(dǎo)航系統(tǒng),abs防抱死系統(tǒng),制動系統(tǒng)等等。 此外,單片機(jī)在工商,金融,科研、教育,國防航空航天等領(lǐng)域都有著十分廣泛的用途。附錄二:外文資料原文Singlechip ponentsTo autoplete singlechip basis, it should be the most important part of what it? Calculated as an example we calculate on an abacus math problems together. Cases: 36 +163 156166 247。 34. Now to carry out operations, first of all need a plan, followed by Pen and paper. We have to calculate the issue of record, and then count the first step, 163 156, add it with the results of 36 recorded in the paper, and then calculate 166 247。 34, then it results from a minus, it has been the final oute. Now, we use singlechip to plete the process, it is clear that it should be instead of thinking first of all the ponents for puting, which is the calculator。 Secondly, there must be able to play the role of devices, which can remember the original subject, the raw data and intermediate results, but also remember to enable singlechip operation can be automatically prepared by the various orders. These devices called memory. In addition, the need to replace the role of the controller, it will be in accordance with an order prior to issuing various control signals so that the whole process can be calculated step by step manner. However, this threepart light enough, the original data and mands to be input, the results of the calculation to the output, are required by the order in which they sometimes need to wait. The first step: the first number from its storage unit (Location) in the check out to the puting device. Step two: the second number from its storage unit in the check out to the puting device。 the third step: add。 fourth step: End the sum of the results to the specified memory unit. All of these take a number, send a few, the sum of deposit, etc. are a few operations (Operation), we asked the puter to operate with the implementation of the various forms of writing down the order, which is instruction. But how can we identify them and to perform these operations? This is a single chip in the design by the designers of the instruction given to it by decision. A mand, corresponding to a basic operation。 single chip can implement all the mands, the mand is the singlechip system (Iustruction Set), different types of singlechip, and its mand system is also different. The use of singlechip, the prior should be the problem to be solved into a series of mands. These instructions must be selected to identify and implement singlechip instructions. Singlechip customers to solve their own problems by the instructions for the procedure, known as source code