版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、.DescriptionThe AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash Programmable and Erasable Read Only Memory (PEROM) and 128 bytes RAM. The device is manufactured using Atmels high density nonvolatile memory technology and is compatible with the industry standa
2、rd MCS-51 instruction set and pinout. The chip combines a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications.Features: Compatible with MCS-51 Products 4K
3、 Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-Level Program Memory Lock 128 x 8-Bit Internal RAM 32 Programmable I/O Lines Two 16-Bit Timer/Counters Six Interrupt Sources Programmable Serial Channel Low Power Idle and
4、 Power Down ModesThe AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition, the AT89C51 is designed
5、 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 Power Down Mode saves the RAM contents but freezes the os
6、cillator disabling all other chip functions until the next hardware reset.Pin Description:VCC Supply voltage.GND Ground.Port 0Port 0 is an 8-bit open drain bidirectional I/O port. As an output port each pin can sink eight TTL inputs. When is are written to port 0 pins, the pins can be used as high i
7、mpedance inputs. Port 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 pullups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verificati
8、on. External pullups are required during program verification.Port 1Port 1 is an 8-bit bidirectional I/O port with internal pullups. The Port 1 output buffers can sink/source 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. A
9、s 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 2Port 2 is an 8-bit bidirectional I/O port with internal pullups. The Port 2 output bu
10、ffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled 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
11、 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 con
12、tents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.Port 3Port 3 is an 8-bit bidirectional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are
13、 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 features of the AT89C51 as listed below:Po
14、rt pinalternate functionsP3.0rxd (serial input port)P3.1txd (serial output port)P3.2int0 (external interrupt0)P3.3int1 (external interrupt1)P3.4t0 (timer0 external input)P3.5t1 (timer1 external input)P3.6WR (external data memory write strobe)P3.7rd (external data memory read strobe)Port 3 also recei
15、ves some control signals for Flash programming and verification.RSTReset input. A high on this pin for two machine cycles while the oscillator is running resets the device.ALE/PROGAddress Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin
16、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 ALE pulse is skipped during each access to external Data Memory. If
17、 desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.PSENProgram S
18、tore Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.EA/VPPExternal Access Enable. EA must be str
19、apped to GND in order to enable the device to 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 on reset. EA should be strapped to VCC for internal program executions. This pin also receives
20、 the 12-volt programming enable voltage(VPP) during Flash programming, for parts that require 12-volt VPP.XTAL1Input to the inverting oscillator amplifier and input to the internal clock operating circuit.XTAL2Output from the inverting oscillator amplifier.Oscillator CharacteristicsXTAL1 and XTAL2 a
21、re the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 i
22、s 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 ModeIn idle mode, t
23、he 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 sh
24、ould 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 p
25、ins 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.Status of External Pins During Idle and Power Down Modesmode
26、Program memoryALEpsenPort0Port1Port2Port3idleinternal11datadatadataDataIdleExternal11floatDatadataDataPower downInternal00DataDataDataDataPower downExternal00floatdataDatadataPower Down ModeIn the power down mode the oscillator is stopped, and the instruction that invokes power down is the last inst
27、ruction 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 i
28、ts normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.Program Memory Lock BitsOn the chip are three lock bits which can be left unprogrammed (U) or can be programmed (P) to obtain the additional features listed in the table below: Lock Bit Pro
29、tection ModesProgram lock bitsProtection typeLb1 Lb2Lb31UUUNo program lock features2PUUMovc instructions executed from external program memory are disable from fetching code bytes from internal memory, ea is sampled and latched on reset, and further programming of the flash disabled3PPUSame as mode
30、2, also verify is disable.4PPPSame as mode 3, also external execution is disabled.When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset. If the device is powered up without a reset, the latch initializes to a random value, and holds that value until reset i
31、s activated. It is necessary that the latched value of EA be in agreement with the current logic level at that pin in order for the device to function properly.Programming the FlashThe AT89C51 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and r
32、eady to be programmed. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The low voltage programming mode provides a convenient way to program the AT89C51 inside the users system, while the high-voltage programming mode is compatible with
33、 conventional third party Flash or EPROM programmers. The AT89C51 is shipped with either the high-voltage or low-voltage programming mode enabled. The respective top-side marking and device signature codes are listed in the following table.Vpp=12vVpp=5vTop-side markAT89C51xxxxyywwAT89C51xxxx-5yywwsi
34、gnature(030H)=1EH(031H)=51H(032H)=FFH(030H)=1EH(031H)=51H(032H)=05HThe AT89C51 code memory array is programmed byte-bybyte in either programming mode. To program any nonblank byte in the on-chip Flash Programmable and Erasable Read Only Memory, the entire memory must be erased using the Chip Erase M
35、ode.Programming Algorithm:Before programming the AT89C51, the address, data and control signals should be set up according to the Flash programming mode table and Figures 3 and 4. To program the AT89C51, take the following steps.1. Input the desired memory location on the address lines.2. Input the
36、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 tha
37、n 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object reached.Data PollingThe 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 comple
38、ment 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.Ready/BusyThe progress of byte programming can also be monitored by the RDY/BSY output
39、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 veri
40、fication. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled.Chip EraseThe entire Flash Programmable and Erasable Read Only Memory array is erased electrically by using the proper combination of control signals and by hol
41、ding 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.Reading the Signature Bytes The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, excep
42、t that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows.(030H) = 1EH indicates manufactured by Atmel(031H) = 51H indicates 89C51(032H) = FFH indicates 12V programming(032H) = 05H indicates 5V programmingProgramming InterfaceEvery code byte in the Flash array can be wri
43、tten 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.描述AT89C51是美國ATMEL公司生產(chǎn)的低電壓,高性能CMOS8位單片機,片內(nèi)含4Kbytes的快速可擦寫的只讀程序存儲器(PEROM)和128bytes的隨機存取數(shù)據(jù)存儲器(RAM),器件采用
44、ATMEL公司的高密度、非易失性存儲技術(shù)生產(chǎn),兼容標準MCS-51產(chǎn)品指令系統(tǒng),片內(nèi)置通用8位中央處理器(CPU)和flish存儲單元,功能強大AT89C51單片機可為您提供許多高性價比的應用場合,可靈活應用于各種控制領(lǐng)域。主要性能參數(shù):與MCS-51產(chǎn)品指令系統(tǒng)完全兼容4K字節(jié)可重復寫flash閃速存儲器1000次擦寫周期全靜態(tài)操作:0HZ24MHZ三級加密程序存儲器128*8字節(jié)內(nèi)部RAM32個可編程I/O口2個16位定時計數(shù)器6個中斷源可編程串行UART通道低功耗空閑和掉電模式功能特性概述AT89C51提供以下標準功能:4K字節(jié)flish閃速存儲器,128字節(jié)內(nèi)部RAM,32個I/O口線
45、,兩個16位定時計數(shù)器,一個5向量兩級中斷結(jié)構(gòu),一個全雙工串行通信口,片內(nèi)振蕩器及時鐘電路。同時,AT89C51可降至0HZ的靜態(tài)邏輯操作,并支持兩種軟件可選的節(jié)電工作模式??臻e方式停止CPU的工作,但允許RAM,定時計數(shù)器,串行通信口及中斷系統(tǒng)繼續(xù)工作。掉電方式保存RAM中的內(nèi)容,但振蕩器停止工作并禁止其它所有部件工作直到下一個硬件復位。引腳功能說明VCC:電源電壓GND:地P0口:P0口是一組8位漏極開路型雙向I/O口,也即地址/數(shù)據(jù)總線復位口。作為輸出口用時,每位能吸收電流的方式驅(qū)動8個邏輯門電路,對端口寫“1”可 作為高阻抗輸入端用。在訪問外部數(shù)據(jù)存儲器或程序存儲器時,這組口線分時轉(zhuǎn)換
46、地址(低8位)和數(shù)據(jù)總線復用,在訪問期間激活內(nèi)部上拉電阻。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)部存在上拉電阻,某
47、個引腳被外部信號拉低時會輸出一個電流(Iil)。在訪問外部程序存儲器獲16位地址的外部數(shù)據(jù)存儲器(例如執(zhí)行MOVXDPTR指令)時,P2口送出高8位地址數(shù)據(jù)。在訪問8位地址的外部數(shù)據(jù)存儲器(如執(zhí)行MOVXRI指令)時,P2口線上的內(nèi)容(也即特殊功能寄存器(SFR)區(qū)中R2寄存器的內(nèi)容),在整個訪問期間不改變。Flash編程或校驗時,P2亦接受高地址和其它控制信號。P3口P3口是一組帶有內(nèi)部上拉電阻的8位雙向I/O口。P3口輸出緩沖級可驅(qū)動(吸收或輸出電流)4個TTL邏輯門電路。對P3口寫入“1”時,他們被內(nèi)部上拉電阻拉高并可作為輸出口。做輸出端時,被外部拉低的P3口將用上拉電阻輸出電流(Iil
48、)。P3口除了作為一般的I/O口線外,更重要的用途是它的第二功能,如下表所示:端口引腳第二功能P3.0rxd (串行輸入口)P3.1txd (串行輸出口)P3.2int0 (外中斷0)P3.3int1 (外中斷1)P3.4t0 (定時/計數(shù)器0)P3.5t1 (定時/計數(shù)器1)P3.6WR (外部數(shù)據(jù)存儲器寫選通)P3.7RD (外部數(shù)據(jù)存儲器讀選通)P3口還接收一些用于flash閃速存儲器編程和程序校驗的控制信號。RST 復位輸入。當振蕩器工作時,RST引腳出現(xiàn)兩個機器周期以上高電平將使單片機復位。ALE/PROG當訪問外部程序存儲器或數(shù)據(jù)存儲器時,ALE(地址所存允許)輸出脈沖用于所存地址
49、的低8位字節(jié)。即使不訪問外部存儲器,ALE仍以時鐘振蕩頻率的1/6輸出固定的正脈沖信號,因此它可對外輸出時鐘或用于定時目的。要注意的是:每當訪問外部數(shù)據(jù)存儲器時將跳過一個ALE脈沖。對flash存儲器編程期間,該引腳還用于輸入編程脈沖(PROG)。如有不要,可通過對特殊功能寄存器(SFR)區(qū)中的8EH單元的D0位置位,可禁止ALE操作。該外置位后,只要一條MOVX和MOVC指令ALE才會被激活。此外,該引腳會被微弱拉高,單片機執(zhí)行外部程序時,應設(shè)置ALE無效。PSEN程序存儲允許(PSEN)輸出是外部程序存儲器的讀選通信號,當AT89C51由外部程序存儲器取指令(或數(shù)據(jù))時,每個機器周期兩個P
50、SEN有效,即輸出兩個脈沖。在此期間,當訪問外部數(shù)據(jù)存儲器,這兩次有效的PSEN信號不出現(xiàn)。EA/VPP外部訪問允許。欲使CPU僅訪問外部程序存儲器(地址為0000H-FFFFH),EA端必須保持低電平(接地)。需注意的是; 如果加密位LB1被編程,復位時內(nèi)部會鎖存EA端狀態(tài)。如 EA端為高電平(接VCC端),CPU則執(zhí)行內(nèi)部程序存儲器中的指令。Flash存儲器編程時,該引腳加上+12V的編程允許電源VPP,當然這必須是該器件是使用12V編程電壓VPP.XTAL1: 振蕩器反相放大器的及內(nèi)部時鐘發(fā)生器的輸出端。XTAL2: 振蕩器反相放大器的輸出端。時鐘振蕩器AT89C51中有一個用于構(gòu)成內(nèi)部
51、振蕩器的高增益反相放大器,引腳XTAL1和XTAL2分別是該放大器的輸入端和輸出端。這個放大器與作為反饋的片外石英晶體或陶瓷諧振器一起構(gòu)成自激振蕩器,振蕩電路參見圖5。外接石英晶體(或陶瓷諧振器)及電容C1、C2接在放大器的反饋回路中構(gòu)成并聯(lián)振蕩電路。對外接電容C1、C2雖然沒有十分嚴格的要求,但電容容量的大小會輕微影響振蕩頻率的高低、振蕩器的穩(wěn)定性、起振的難易程度及溫度穩(wěn)定性,如果使用石英晶體,我們推薦電容使用30PF+10PF,而如使用陶瓷諧振器建議選擇40PF+10PF。用戶也可以采用外部時鐘。采用外部時鐘的電路如圖5右所示。這種情況下,外部時鐘脈沖接到XTAL1端,即內(nèi)部時鐘發(fā)生器的輸
52、入端,XTAL2則懸空由于外部時鐘信號是通過一個2分頻觸發(fā)器后作為內(nèi)部時鐘信號的,所以對外部時鐘信號的占空比沒有特殊要求,但最小高電平持續(xù)時間和最大的低電平持續(xù)時間應符合產(chǎn)品技術(shù)要求??臻e模式在空閑工作模式狀態(tài),CPU保持睡眠狀態(tài)而所有片內(nèi)的外設(shè)仍保持激活狀態(tài),這種方式由軟件產(chǎn)生。此時,片內(nèi)RAM和所有特殊功能寄存器的內(nèi)容保持不變??臻e模式可由任何允許的中斷請求或硬件復位終止。終止空閑工作模式的方法有兩種,其一是任何一條被允許中斷的事件被激活,即可終止空閑工作模式。程序會首先響應中斷,進入中斷服務程序,執(zhí)行完中斷服務程序并僅隨終端返回指令,下一條要執(zhí)行的指令就是使單片機進入空閑模式那條指令后面
53、的一條指令。其二是通過硬件復位也可將空閑工作模式終止,需要注意的是,當由硬件復位來終止空閑模式時,CPU通常是從激活空閑模式那條指令的下一條指令開始繼續(xù)執(zhí)行程序的,要完成內(nèi)部復位操作,硬件復位脈沖要保持兩個機器周期(24個時鐘周期)有效,在這種情況下,內(nèi)部禁止CPU訪問片內(nèi)RAM,而允許訪問其它端口。為了避免可能對端口產(chǎn)生以外寫入,激活空閑模式的那條指令后一條指令不應該是一條對端口或外部存儲器的寫入指令??臻e和掉電模式外部引腳狀態(tài)模式程序存儲器ALEPSENPORT0PORT1PORT2PORT3空閑模式內(nèi)部11數(shù)據(jù)數(shù)據(jù)數(shù)據(jù)數(shù)據(jù)空閑模式外部11浮空數(shù)據(jù)數(shù)據(jù)數(shù)據(jù)掉電模式內(nèi)部00數(shù)據(jù)數(shù)據(jù)數(shù)據(jù)數(shù)據(jù)掉電模式外部00浮空數(shù)據(jù)數(shù)據(jù)數(shù)據(jù)掉電模式在掉電模式下,震蕩器停止工作,進入掉電模式的指令是最后一條被執(zhí)行的指令,片內(nèi)RAM和特殊功能寄存器的內(nèi)容在終止掉電模式前被凍結(jié)。退出掉電模式的唯一方法是硬件復位,復位
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年冀教新版選擇性必修1生物下冊階段測試試卷含答案
- 二零二五年度城市綜合體夜間安全管理打更合同3篇
- 房屋出租做旅社合同(2篇)
- 2025版城市軌道交通沿線商鋪租賃合同示范文本4篇
- 個人資金借給公司合同范本(2024版)版B版
- 2025版南寧國際學校教育設(shè)施租賃合同及學生教育服務協(xié)議3篇
- 個性化離婚合同模板2024年版B版
- 2025年度門窗配件專業(yè)供應商合同4篇
- 2025技術(shù)員派遣及系統(tǒng)集成服務合同3篇
- 2025年度生態(tài)園區(qū)墻面生態(tài)防護合同標的協(xié)議書4篇
- 南通市2025屆高三第一次調(diào)研測試(一模)地理試卷(含答案 )
- 2025年上海市閔行區(qū)中考數(shù)學一模試卷
- 2025中國人民保險集團校園招聘高頻重點提升(共500題)附帶答案詳解
- 重癥患者家屬溝通管理制度
- 法規(guī)解讀丨2024新版《突發(fā)事件應對法》及其應用案例
- IF鋼物理冶金原理與關(guān)鍵工藝技術(shù)1
- 銷售提成對賭協(xié)議書范本 3篇
- 勞務派遣招標文件范本
- EPC項目階段劃分及工作結(jié)構(gòu)分解方案
- 小學二年級數(shù)學口算練習題1000道
- 家譜、宗譜頒譜慶典講話
評論
0/150
提交評論