基于單片機的檔案庫房溫濕度監(jiān)控系統(tǒng)設(shè)計
基于單片機的檔案庫房溫濕度監(jiān)控系統(tǒng)設(shè)計,基于,單片機,檔案,庫房,溫濕度,監(jiān)控,系統(tǒng),設(shè)計
畢 業(yè) 設(shè) 計(論 文)外 文 參 考 資 料 及 譯 文
譯文題目:The General Situation of AT89C51
AT89C51應(yīng)用
學(xué)生姓名:
專 業(yè):
所在學(xué)院:
指導(dǎo)教師:
職 稱:
AT89C51的概況
The General Situation of AT89C51
Chapter 1 The application of AT89C51
Microcontrollers are used in a multitude of commercial applications such as modems, motor-control systems, air conditioner control systems, automotive engine and among others. The high processing speed and enhanced peripheral set of these microcontrollers make them suitable for such high-speed event-based applications. However, these critical application domains also require that these microcontrollers are highly reliable. The high reliability and low market risks can be ensured by a robust testing process and a proper tools environment for the validation of these microcontrollers both at the component and at the system level. Intel Plaform Engineering department developed an object-oriented multi-threaded test environment for the validation of its AT89C51 automotive microcontrollers. The goals of thisenvironment was not only to provide a robust testing environment for the AT89C51 automotive microcontrollers, but to develop an environment which can be easily extended and reused for the validation of several other future microcontrollers. The environment was developed in conjunction with Microsoft Foundation Classes (AT89C51). The paper describes the design and mechanism of this test environment, its interactions with various hardware/software environmental components, and how to use AT89C51.
1.1 Introduction
The 8-bit AT89C51 CHMOS microcontrollers are designed to handle high-speedcalculations and fast input/output operations. MCS 51 microcontrollers are typically used for high-speed event control systems. Commercial applications include modems,motor-control systems, printers, photocopiers, air conditioner control systems, disk drives,and medical instruments. The automotive industry use MCS 51 microcontrollers in engine-control systems, airbags, suspension systems, and antilock braking systems (ABS). The AT89C51 is especially well suited to applications that benefit from its processing speed and enhanced on-chip peripheral functions set, such as automotive power-train control, vehicle dynamic suspension, antilock braking, and stability control applications. Because of these critical applications, the market requires a reliable cost-effective controller with a low interrupt latency response, ability to service the high number of time and event driven integrated peripherals needed in real time applications, and a CPU with above average processing power in a single package. The financial and legal risk of having devices that operate unpredictably is very high. Once in the market, particularly in mission criticalapplications such as an autopilot or anti-lock braking system, mistakes are financiallyprohibitive. Redesign costs can run as high as a $500K, much more if the fix means 2 back annotating it across a product family that share the same core and/or peripheral design flaw. In addition, field replacements of components is extremely expensive, as the devices are typically sealed in modules with a total value several times that of the component. To mitigate these problems, it is essential that comprehensive testing of the controllers be carried out at both the component level and system level under worst case environmental and voltage conditions.This complete and thorough validation necessitates not only a well-defined process but also a proper environment and tools to facilitate and execute the mission successfully.Intel Chandler Platform Engineering group provides post silicon system validation (SV) of various micro-controllers and processors. The system validation process can be broken into three major parts.The type of the device and its application requirements determine which types of testing are performed on the device.
1.2 The AT89C51 provides the following standard features:
4Kbytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bittimer/counters, a five vector two-level interrupt architecture,a full duple ser -ial port, on-chip 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 sys -tem to continue functioning. The Power-down Mode saves the RAM contents but freezes the oscil –lator disabling all other chip functions until the next hardware reset.
Figure 1-2-1Block Diagram
1-3Pin Description
VCC Supply voltage.
GND Ground.
Port 0:Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin cansink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs.Port 0 may also be configured to be the multiplexed loworder address/data busduring accesses to external program and data memory. In this mode P0 has internalpullups.Port 0 also receives the code bytes during Flash programming,and outputs the codebytes during program verification. External pullups are required during programverification.
Port 1:Port 1 is an 8-bit bi-directional I/O port with internal pullups.The Port 1 output buffers can sink/so -urce four TTL inputs.When 1s are written to Port 1 pins they are 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 pullups.Port 1 also receives the low-order address bytes during Flash programming and verification.
Port 2:Port 2 is an 8-bit bi-directional I/O port with internal pullups.The Port 2 outputbuffers can sink/source four TTL inputs.When 1s are written to Port 2 pins they arepulled high by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups.Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX@DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register.Port 2 also receives the high-order address bits and some control signals durin Flash programming and verification.
Port 3:Port 3 is an 8-bit bi-directional I/O port with internal pullups.The Port 3 outputbuffers can sink/sou -rce four TTL inputs.When 1s are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. As inputs,Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups.
Port 3 also serves the functions of various special featuresof the AT89C51 as listed below:
RST:Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.
ALE/PROG:Address Latch Enable output pulse for latching the low byte of the address duringaccesses to external memory.This pin is also the program pulse input (PROG) during Flash programming.In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency,and may be used for external timing or clocking purposes. Note, however, that one ALEpulse is skipped duri -ng each access to external DataMemory.If desired, ALE operationcan be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active onlyduring a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Settingthe ALE-disable bit has no effect if the microcontroller is in external execution mode.
PSEN:Program Store Enable is the read strobe to external program memory. When theAT89C51 is executing code from external program memory, PSEN is activated twiceeach machine cycle, except that two PSEN activations are skipped during each access toexternal data memory.
EA/VPP:External Access Enable. EA must be strapped to GND in order to enable the deviceto fetch code from external program memory locations starting at 0000H up to FFFFH.Note, however, that if lock bit 1 is programmed, EA will be internally latched onreset.EA should be strapped to VCC for internal program executions. This pin alsreceives the 12-volt programming enable voltage (VPP) during Flash programming, forparts that require 12-volt VPP.
XTAL1:Input to the inverting oscillator amplifier and input to the internal clock operatingcircuit.
XTAL2 :Output from the inverting oscillator amplifier.Oscillator CharacteristicsXTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifierwhich can be configured for use as an on-chip oscillator, as shown in Figure 1. Either aquartz crystal or ceramic resonator may be used. To drive the device from an externalclock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 2.There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed. Idle Mode In idle mode, the CPU puts itself to sleep while all the onchip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hard ware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.
Power-down Mode
In the power-down mode, the oscillator is stopped, and the instruction that invokes power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power-down mode is terminated. The only exit from power-down is a hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.The AT89C51 code memory array is programmed byte-bybyte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode.
2 Programming Algorithm
Before programming the AT89C51, the address, data and control signals should be set up according to the Flash programming mode table and Figure 3 and Figure 4. To program the AT89C51, take the following steps.1. Input the desired memory location on the address lines.2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V for the high-voltage programming mode. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached. Data Polling: The AT89C51 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written datum on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated.
2.1Ready/Busy:
The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY.
Program Verify:
If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled.
Figure 2-1-1 Programming the Flash Figure 2-2-2 Verifying the Flash
2.2 Chip Erase:
The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all “1”s. The chip erase operation must be executed before the code memory can be re-programmed.
2.3 Reading the Signature Bytes:
The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned areas follows.
(030H) = 1EH indicates manufactured by Atmel
(031H) = 51H indicates 89C51
(032H) = FFH indicates 12V programming
(032H) = 05H indicates 5V programming
2.4 Programming Interface
Every code byte in the Flash array can be written and the entire array can be erased by using the appropriate combination of control signals. The write operation cycle is selftimed and once initiated, will automatically time itself to completion. A microcomputer interface converts information between two forms. Outside the microcomputer the information handled by an electronic system exists as a physical signal, but within the program, it is represented numerically. The function of any interface can be broken down into a number of operations which modify the data in some way, so that the process of conversion between the external and internal forms is carried out in a number of steps. An analog-to-digital converter(ADC) is used to convert a continuously variable signal to a corresponding digital form which can take any one of a fixed number of possible binary values. If the output of the transducer does not vary continuously, no ADC is necessary. In this case the signal conditioning section must convert the incoming signal to a form which can be connected directly to the next part of the interface, the input/output section of the microcomputer itself. Output interfaces take a similar form, the obvious difference being that here the flow of information is in the opposite direction; it is passed from the program to the outside world. In this case the program may call an output subroutine which supervises the operation of the interface and performs the scaling numbers which may be needed for digital-to-analog converter(DAC). This subroutine passes information in turn to an output device which produces a corresponding electrical signal, which could be converted into analog form using a DAC. Finally the signal is conditioned(usually amplified) to a form suitable for operating an actuator. The signals used within microcomputer circuits are almost always too small to be connected directly to the outside world” and some kind of interface must be used to translate them to a more appropriate form. The design of section of interface circuits is one of the most important tasks facing the engineer wishing to apply microcomputers. We have seen that in microcomputers information is represented as discrete patterns of bits; this digital form is most useful when the microcomputer is to be connected to equipment which can only be switched on or off, where each bit might represent the state of a switch or actuator. To solve real-world problems, a microcontroller must have more than just a CPU, a program, and a data memory. In addition, it must contain hardware allowing the CPU to access information from the outside world. Once the CPU gathers information and processes the data, it must also be able to effect change on some portion of the outside world. These hardware devices, called peripherals, are the CPU’s window to the outside.
The most basic form of peripheral available on microcontrollers is the general purpose I70 port. Each of the I/O pins can be used as either an input or an output. The function of each pin is determined by setting or clearing corresponding bits in a corresponding data direction register during the initialization stage of a program. Each output pin may be driven to either a logic one or a logic zero by using CPU instructions to pin may be viewed (or read.) by the CPU using program instructions. Some type of serial unit is included on microcontrollers to allow the CPU to communicate bit-serially with external devices. Using a bit serial format instead of bit-parallel format requires fewer I/O pins to perform the communication function, which makes it less expensive, but slower. Serial transmissions are performed either synchronously or asynchronously.
翻譯
AT89C51的概況
1 AT89C51應(yīng)用
單片機廣泛應(yīng)用于商業(yè):諸如調(diào)制解調(diào)器,電動機控制系統(tǒng),空調(diào)控制系統(tǒng),汽車發(fā)動機和其他一些領(lǐng)域。這些單片機的高速處理速度和增強型外圍設(shè)備集合使得它們適合于這種高速事件應(yīng)用場合。然而,這些關(guān)鍵應(yīng)用領(lǐng)域也要求這些單片機高度可靠。健壯的測試環(huán)境和用于驗證這些無論在元部件層次還是系統(tǒng)級別的單片機的合適的工具環(huán)境保證了高可靠性和低市場風(fēng)險。Intel 平臺工程部門開發(fā)了一種面向?qū)ο蟮挠糜隍炞C它的AT89C51 汽車單片機多線性測試環(huán)境。這種環(huán)境的目標(biāo)不僅是為AT89C51 汽車單片機提供一種健壯測試環(huán)境,而且開發(fā)一種能夠容易擴展并重復(fù)用來驗證其他幾種將來的單片機。開發(fā)的這種環(huán)境連接了AT89C51。本文討論了這種測試環(huán)境的設(shè)計和原理,它的和各種硬件、軟件環(huán)境部件的交互性,以及如何使用AT89C51。
1.1 介紹
8 位AT89C51 CHMOS 工藝單片機被設(shè)計用于處理高速計算和快速輸入/輸出。MCS51 單片機典型的應(yīng)用是高速事件控制系統(tǒng)。商業(yè)應(yīng)用包括調(diào)制解調(diào)器,電動機控制系統(tǒng),打印機,影印機,空調(diào)控制系統(tǒng),磁盤驅(qū)動器和醫(yī)療設(shè)備。汽車工業(yè)把MCS51 單片機用于發(fā)動機控制系統(tǒng),懸掛系統(tǒng)和反鎖制動系統(tǒng)。AT89C51 尤其很好適用于得益于它的處理速度和增強型片上外圍功能集,諸如:汽車動力控制,車輛動態(tài)懸掛,反鎖制動和穩(wěn)定性控制應(yīng)用。由于這些決定性應(yīng)用,市場需要一種可靠的具有低干擾潛伏響應(yīng)的費用-效能控制器,服務(wù)大量時間和事件驅(qū)動的在實時應(yīng)用需要的集成外圍的能力,具有在單一程序包中高出平均處理功率的中央處理器。擁有操作不可預(yù)測的設(shè)備的經(jīng)濟(jì)和法律風(fēng)險是很高的。一旦進(jìn)入市場,尤其任務(wù)決定性應(yīng)用諸如自動駕駛儀或反鎖制動系統(tǒng),錯誤將是財力上所禁止的。重新設(shè)計的費用可以高達(dá)500K 美元,如果產(chǎn)品族享有同樣內(nèi)核或外圍設(shè)計缺陷的話,費用會更高。另外,部件的替代品領(lǐng)域是極其昂貴的,因為設(shè)備要用來把模塊典型地焊接成一個總體的價值比各個部件高幾倍。為了緩和這些問題,在最壞的環(huán)境和電壓條件下對這些單片機進(jìn)行無論在部件級別還是系統(tǒng)級別上的綜合測試是必需的。Intel Chandler 平臺工程組提供了各種單片機和處理器的系統(tǒng)驗證。這種系統(tǒng)的驗證處理可以被分解為三個主要部分。系統(tǒng)的類型和應(yīng)用需求決定了能夠在設(shè)備上執(zhí)行的測試類型。
1.2 AT89C51提供以下標(biāo)準(zhǔn)功能:
4k 字節(jié)FLASH 閃速存儲器,128 字節(jié)內(nèi)部RAM,32 個I/O 口線,2 個16 位定時/計數(shù)器,一個5 向量兩級中斷結(jié)構(gòu),一個全雙工串行通信口,片內(nèi)振蕩器及時鐘電路。同時,AT89C51 降至0Hz 的靜態(tài)邏輯操作,并支持兩種可選的節(jié)電工作模式??臻e方式體制CPU 的工作,但允許RAM,定時/計數(shù)器,串行通信口及中斷系統(tǒng)繼續(xù)工作。掉電方式保存RAM 中的內(nèi)容,但振蕩器體制工作并禁止其他所有不見工作直到下一個硬件復(fù)位。
圖1-2-1 AT89C51 方框圖
1.3引腳功能說明
·Vcc:電源電壓
·GND:地
·P0 口:P0 口是一組8 位漏極開路型雙向I/O 口,也即地址/數(shù)據(jù)總線復(fù)用。作為輸出口用時,每位能吸收電流的方式驅(qū)動8 個TTL 邏輯門電路,對端口寫“1”可作為高阻抗輸入端用。在訪問外部數(shù)據(jù)存儲器或程序存儲器時,這組口線分時轉(zhuǎn)換地址(低8 位)和數(shù)據(jù)總線復(fù)用,在訪問期間激活內(nèi)部上拉電阻。在Flash 編程時,P0 口接受指令字節(jié),而在程序校驗時,輸出指令字節(jié),校驗時,要求外接上拉電阻。
·P1 口:P1 是一個帶內(nèi)部上拉電阻的8 位雙向I/O 口,P1 的輸出緩沖級可驅(qū)動(吸收或輸出電流)4 個TTL 邏輯門電路。對端口寫“1”,通過內(nèi)部的上拉電阻把端口拉到高電平,此時可作輸入口。作為輸入口使用時,因為內(nèi)部存在上拉電阻,某個引腳被外部信號拉低時會輸出一個電流(IIL)。Flash 編程和程序校驗期間,P1 接受低8 位地址。
·P2 口:P2 是一個帶有內(nèi)部上拉電阻的8 位雙向I/O 口,P2 的輸出緩沖級可驅(qū)動(吸收或輸出電流)4 個TTL 邏輯門電路。對端口寫“1”,通過內(nèi)部的上拉電阻把端口拉到高電平,此時可作輸入口。作為輸入口使用時,因為內(nèi)部存在上拉電阻,某個引腳被外部信號拉低時會輸出一個電流(IIL)。在訪問外部程序存儲器或16 位四肢的外部數(shù)據(jù)存儲器(例如執(zhí)行MOVX @DPTR指令)時,P2 口送出高8 位地址數(shù)據(jù),在訪問8 位地址的外部數(shù)據(jù)存儲器(例如執(zhí)行MOVX @ RI 指令)時,P2 口線上的內(nèi)容(也即特殊功能寄存器(SFR)區(qū)中R2 寄存器的內(nèi)容),在整個訪問期間不改變。Flash 編程和程序校驗時,P2 也接收高位地址和其他控制信號。
·P3 口:P3 是一個帶有內(nèi)部上拉電阻的8 位雙向I/O 口,P3 的輸出緩沖級可驅(qū)動(吸收或輸出電流)4 個TTL 邏輯門電路。對端口寫“1”,通過內(nèi)部的上拉電阻把端口拉到高電平,此時可作輸入口。作為輸入口使用時,因為內(nèi)部存在上拉電阻,某個引腳被外部信號拉低時會輸出一個電流(IIL)。P3 口還接收一些用于Flash 閃速存儲器編程和程序校驗的控制信號。
·RST:復(fù)位輸入。當(dāng)振蕩器工作時,RST 引腳出現(xiàn)兩個機器周期以上高電平將使單片機復(fù)位。
·ALE/PROG:當(dāng)訪問外部程序存儲器或數(shù)據(jù)存儲器時,ALE(地址鎖存允許)輸出脈沖用于鎖存地址的低8 位字節(jié)。即使不訪問外部存儲器,ALE 仍以時鐘振蕩頻率的1/6 輸出固定的正脈沖信號,因此它可對外輸出時鐘或用于定時目的。要注意的是,每當(dāng)訪問外部數(shù)據(jù)存儲器時將跳過一個ALE 脈沖。對Flash 存儲器編程期間,該引腳還用于輸入編程脈沖(PROG)。如有必要,可通過對特殊功能寄存器(SFR)區(qū)中的8EH 單元D0 位置位,可禁止ALE 操作。該位置位后,只有一條MOVX 和MOVC 指令A(yù)LE 才會被激活。此外,該引腳會被微弱拉高,單片機執(zhí)行外部程序時,應(yīng)設(shè)置ALE 無效。
·PSEN:程序存儲允許輸出是外部程序存儲器的讀選通型號,當(dāng)89C51 由外部存儲器取指令(或數(shù)據(jù))時,每個機器周期兩次PSEN 有效,即輸出兩個脈沖。在此期間,當(dāng)訪問外部數(shù)據(jù)存儲器,這兩次有效的PSEN 信號不出現(xiàn)。
·EA/VPP
收藏