【正文】
ing 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 211 Programming the Flash Figure 222 Verifying the Flash Chip Erase: The entire Flash array is erased electrically by using the proper bination 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 reprogrammed. 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 and 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 Programming Interface Every code byte in the Flash array can be written and the entire array can be erased by using the appropriate bination of control signals. The write operation cycle is self timed and once initiated, will automatically time itself to pletion. A microputer interface converts information between two forms. Outside the microputer 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 analogtodigital converter 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 ining signal to a form which can be connected directly to the next part of the interface, the input/output section of the microputer itself. Output interfaces take a similar form, the obvious difference being that here the flow of information is in the opposite direction。然而,這些關(guān)鍵應(yīng)用領(lǐng)域也要求這些單片機(jī)高度可靠。開(kāi)發(fā)的這種環(huán)境連接了AT89C51。商業(yè)應(yīng)用包括調(diào)制解調(diào)器,電動(dòng)機(jī)控制系統(tǒng),打印機(jī),影印機(jī),空調(diào)控制系統(tǒng),磁盤(pán)驅(qū)動(dòng)器和醫(yī)療設(shè)備。擁有操作不可預(yù)測(cè)的設(shè)備的經(jīng)濟(jì)和法律風(fēng)險(xiǎn)是很高的。為了緩和這些問(wèn)題,在最壞的環(huán)境和電壓條件下對(duì)這些單片機(jī)進(jìn)行無(wú)論在部件級(jí)別還是系統(tǒng)級(jí)別上的綜合測(cè)試是必需的。 AT89C51提供以下標(biāo)準(zhǔn)功能: 4k 字節(jié) FLASH 閃速存儲(chǔ)器 , 128 字節(jié)內(nèi)部 RAM, 32 個(gè) I/O 口線, 2 個(gè)16 位定時(shí) /計(jì)數(shù)器,一個(gè) 5 向量?jī)杉?jí)中斷結(jié)構(gòu),一個(gè)全雙工串行通信口,片內(nèi)振蕩器及時(shí)鐘電路。 圖 121 AT89C51 方框圖 作為輸出口用時(shí),每位能吸收電流的方式驅(qū)動(dòng) 8 個(gè) TTL 邏輯門(mén)電路,對(duì)端口寫(xiě)“ 1”可作為高阻抗輸入端用。 P1 口: P1 是一個(gè)帶內(nèi)部上拉電阻的 8 位雙向 I/O 口, P1 的輸出緩沖級(jí)可驅(qū) 動(dòng)(吸收或輸出電流) 4 個(gè) TTL 邏輯門(mén)電路。 在訪問(wèn)外部程序存儲(chǔ)器或 16 位四肢的外部數(shù)據(jù)存儲(chǔ)器(例如執(zhí)行 MOVX DPTR指令)時(shí), P2 口送出高 8 位地址數(shù)據(jù),在訪問(wèn) 8 位地址的外部數(shù)據(jù)存儲(chǔ)器(例如執(zhí)行MOVX RI 指令)時(shí), P2 口線上的內(nèi)容(也即特殊功能寄存器( SFR)區(qū)中R2 寄存器的內(nèi)容),在整個(gè)訪問(wèn)期間不改變。對(duì)端口寫(xiě)“ 1”,通過(guò)內(nèi)部的上拉電阻把端口拉到高電平,此時(shí)可作輸入口。 RST:復(fù)位輸入。即使不訪問(wèn)外部存儲(chǔ)器, ALE 仍以時(shí)鐘振蕩頻率的 1/6 輸出 固定的正脈沖信號(hào),因此它可對(duì)外輸出時(shí)鐘或用于定時(shí)目的。該位置位后,只有一條 MOVX 和 MOVC 指令 ALE 才會(huì)被激活。在此期間,當(dāng)訪問(wèn)外部數(shù)據(jù)存儲(chǔ)器,這兩次有效的 PSEN 信號(hào)不出現(xiàn)。需注意的是:如果加密位 LB1 被編程,復(fù)位時(shí)內(nèi)部會(huì)鎖存 EA 端狀態(tài)。 XTAL1:振蕩器反相放大器及內(nèi)部時(shí)鐘發(fā)生器的輸入端。這個(gè)放大器與作為反饋元件的片外石英晶體或陶瓷諧振器一起構(gòu)成自激振蕩器,振蕩電路參見(jiàn)圖 5。 10Pf。掉電模式: 在掉電模式下,振蕩器停止工作,進(jìn)入掉電模式的指令是最后一條被執(zhí)行的指令,片內(nèi) RAM 和特殊功能寄存器的內(nèi)容在終止掉電模式前被凍結(jié)。編程時(shí),可采用 4— 20MHz 的時(shí)鐘振蕩器, 89C51 編程方法如下:在地址線上加上要編程單元的地址信號(hào)在數(shù)據(jù)線上加上要寫(xiě)入的數(shù)據(jù)字節(jié)。改變編程單元的地址和寫(xiě)入的數(shù)據(jù),重復(fù) 1— 5 步驟,知道全部文件編程結(jié)束。寫(xiě)周期開(kāi)始后,可在任意時(shí)刻進(jìn)行數(shù)據(jù)查詢。程序校驗(yàn):如果加密位 LB、 LB2 沒(méi)有進(jìn)行編程,則代碼數(shù) 據(jù)可通過(guò)地址和數(shù)據(jù)線讀回原編寫(xiě)的數(shù)據(jù),采用下圖的電路,程序存儲(chǔ)器的地址由 P1 口和 P2 口的 — 輸入,數(shù)據(jù)由 P0 口讀出, P20 和 、 的控制信號(hào)見(jiàn)表 6, PSEN 保持低電平, ALE、 EA 和 RST 保持高電平。于聲明該器件的廠商、號(hào)和編程電壓。 (032H) = 05H 聲明為 5 編程電壓。任一接口的功能都可分為以某種形式進(jìn)行數(shù)據(jù)庫(kù)變換的一些操作,所以外部和內(nèi)部形式的轉(zhuǎn)換是由許多步驟完成的。輸出接口采用相似的形式,明顯的差別在于信息流的方向相反;是從程序到外部世界。在微機(jī)電路中使用的信號(hào)幾乎總是太小而不能被直接地連到“外部世界”,因而必須用某種形式將其轉(zhuǎn)換成更適宜的形式。為了解決實(shí)際問(wèn)題,一個(gè)單片機(jī)不僅包括 CPU,程序和數(shù)據(jù)存儲(chǔ)器,另外,它必須含有通過(guò) CPU 訪問(wèn)外部信息的硬件。串口傳送可以同步也可以異步。 單片機(jī)可利用外圍設(shè)備中最基本的用于一般用途的 I/O 接口,每個(gè) I/O 接口既可作為輸入端又可作為輸出端,每個(gè) I/O 接口的功能取決與程序初始化階段對(duì)數(shù)據(jù)方位寄存器相應(yīng)位進(jìn)行置一和清零操作,通過(guò) CPU 指令對(duì)數(shù)據(jù)寄存器相應(yīng)位進(jìn)行置一和清零來(lái)置一和清零輸出端口,同樣輸入端口邏輯位也可以通過(guò) CPU 指令訪問(wèn)。我們已經(jīng)了解到微機(jī)中,信號(hào)以離散的位形式表示。該子程序依次送出信息給輸出器件,產(chǎn)生相應(yīng)的電信號(hào),由 DAC 轉(zhuǎn)換成模擬形式。如果傳感器輸出不是連續(xù)變化的,就不需模擬 數(shù)字轉(zhuǎn)換。微機(jī)接口實(shí)現(xiàn)兩種信息形式的交換。 (031H) = 51H 聲明為 89C51 單片機(jī)。 圖 211 編程電路 圖 222 校驗(yàn)電路 : 利用控制信號(hào)的正確組合 (表 6)并保持 ALE/PROG 引腳 10ms 的低電平脈沖 寬度即可將 EPROM 陣列 (4k 字節(jié) )和三個(gè)加密位整片擦除 ,代碼陣列在片擦除操作中將任何非空單元寫(xiě)入” 1” ,這步驟需在編程之前進(jìn)行。編程完成后, 變?yōu)楦唠娖奖硎緶?zhǔn)備就緒狀態(tài)。在高電壓編程方式時(shí),將 EA/Vpp 端加上 +12v 編 程電壓。 89C51 的程序存儲(chǔ)器陣列是采用字節(jié)寫(xiě)入方式編程的,每次寫(xiě)入一個(gè)字符,要對(duì)整個(gè)芯片的 EPROM 程序存儲(chǔ)器寫(xiě)入一個(gè)非空字節(jié),必須使用片擦除的方法將整個(gè)存儲(chǔ)器的內(nèi)容清楚。這種情