【正文】
rs, and establish a link with the remote modem. Prom Plus includes a macro language called ASPECT, which allows the user to write and pile scripts which implement c ustom file transfer protocols. A simple ASPECT script was written to read the contents of a program file and upload it to the remote programmer. The file transfer protocol (FTP) implemented is a simple sendandwait, packetoriented protocol. The trans mit and receive modes of the FTP are illustrated by the flowcharts in figures 4 and 5, respectively. The transmitter sends each packet without flow control and waits for a response. The programmer (the receiver) reads and dissects the packet while calculating a checksum. If the calculated checksum is valid, the programmer acknowledges the packet by sending an ACK. If the checksum is in error, the programmer negatively acknowledges the packet by sending a NAK. Upon receipt of an ACK, the transmitter sends the next packet. If the transmitter receives a NAK, it resends the same packet. Transmission proceeds in this manner until the entire file has been transferred. The programmer might respond to a packet by sending a CAN, which indicates that a nonrecoverable error has occurred and that the transmitter should immediately abort the file transfer. If the programmer fails to respond to a packet within a limited period of time, the transmitter will resend the same packet. The transmitter will continue to resend the same packet until a valid response is received or until the allowed number of attempts is exceeded, at which time the file transfer is aborted. After each packet is received and validated by the programmer, the data contained in the packet is programmed into the AT89C51 controller in the application. After programming, the data is read back from the controller and verified against the received packet data. Successful verification indicates successful programming, causing the programmer to send ACK to the transmitter. If programming fails, the programmer sends CAN to signal the transmitter to abort the file transfer. The simplicity of the FTP reduces the amount of AT89C51 program memory used in the programmer. The sendand wait nature of the FTP allows interpacket delays due to AT89C51 program and erase times to be easily absorbed. Support for program verification is transparent, requiring no explicit mand or result codes, or additional data transfers. The files which are uploaded to the programmer are created with the tools in the Intel MCS51 Software Development Package for the IBM PC. Included in the package are the MCS51 Macro Assembler, MCS51 Relocator and Linker, and a useful utility, OH. OH converts an absolute 8051 object file to an equivalent ASCII hexadecimal object file. The records in the hex file produced by the OH utility serve, unchanged, as the packets in the FTP described above。應(yīng)用程序使用的外部程序存儲器要求這一腳為低電平才能正常運(yùn)行。帶有三個輸出狀態(tài)的緩沖區(qū)會在應(yīng)用程序之間插入電路和控制器,同時 在編程時緩沖區(qū)輸出三種狀態(tài)。在第一種模式的時候,進(jìn)入一個字符從右邊顯示和快速移動,通過每個元素顯示其在最后的裝配位置的左側(cè)。 支持應(yīng)用程序的修改 。 請注意,加在開關(guān)上的四個電阻在基本應(yīng)用中并不是必須的,因?yàn)?AT89C51的端口上提供一個內(nèi)部上拉電阻。在編程過程中,復(fù)位鍵生效,多路開關(guān)信號輸入,以及凍結(jié)顯示鎖存控制線。該控制器運(yùn)行在 兆 赫茲 ,此頻率允許串口運(yùn)行在一個標(biāo)準(zhǔn)波特率下。這就要求程序代碼和 I / O 緩沖區(qū)保持足夠小以適合片上存儲器。更高的傳輸速度的可能優(yōu)勢是在某些高速調(diào)制解調(diào)器內(nèi)的自動錯誤檢測和糾正。如果計(jì)算 出的校驗(yàn)和是有效的,程序員通過發(fā)送一個 ACK 承認(rèn)此數(shù)據(jù)包。每個數(shù)據(jù)包接收和通過程序員驗(yàn)證后,數(shù)據(jù)包中包含的數(shù)據(jù)被加載到的 AT89C51 單片機(jī)控制器編程。在包中包括了 MCS 51 宏匯編, MCS 51 單片機(jī) Relocator 和連接器,以及一個有用的工具, OH。在配置調(diào)制解調(diào)器接聽來電后,程序控制器停止工作。當(dāng)檢測到輸入,調(diào)制解調(diào)器響應(yīng)并試圖與輸入建 立通信。 兩個數(shù) 據(jù)包類型定義:數(shù)據(jù)和最終文件。編程器給傳送者發(fā)送一個 NAK 作為信號數(shù)據(jù)包的接收和恢復(fù)為一個有效的數(shù)據(jù)包報頭審查的警示信號。由于 30 秒的復(fù)位延遲,編程器重新對有效的數(shù)據(jù)包報頭進(jìn)行測試。 如果一個有效的數(shù)據(jù)包在 30 秒延遲之前接收,另一個只能被接受一個有效的末端文件而終止的程序循環(huán)開始執(zhí)行。在這種情況下應(yīng)用控制器被保留在程序設(shè)計(jì)模式,以防止它執(zhí)行這個程序。調(diào)制解調(diào)器掉線,程序器繼續(xù)休眠等待下一次呼叫。該控制器的中斷響應(yīng)放棄其正在運(yùn)行的程序,并顯示一條消息,表明程序已經(jīng)被替代。數(shù)據(jù)字段包含程序的數(shù)據(jù)在應(yīng)用程序中被寫入在AT89C51 的控制器。程序控制器驗(yàn)證連接的代碼,并開始審查有效的數(shù)據(jù)包報頭。 程序員通過發(fā)送控制在串行接口上的 ASCII 命令字符串來控制調(diào)制解調(diào)器,對此調(diào)制解調(diào)器響應(yīng)海斯式調(diào)制解調(diào)器的 ASCII 數(shù)字代碼。 遠(yuǎn)程配置 在測試配置中的遠(yuǎn)程配置包括顯示應(yīng)用程序和程序員電路,如前所述,連接到一個與 Hayes 兼容的普羅米 修斯 1200 波特調(diào)制解調(diào)器。成功的審查表明,成功的程序設(shè)計(jì),使程序員發(fā)送 ACK 給傳送者。當(dāng)接收一個 ACK 后,發(fā)射器發(fā)送下一個數(shù)據(jù)包。 Prom Plus 包括所謂的宏語言方面,它允許用戶編寫實(shí)現(xiàn)自定義的文件傳輸協(xié)議的腳本。 編程器和前面描述的顯示應(yīng)用是與通過調(diào)制解調(diào)器連接在遠(yuǎn)程站點(diǎn)電話線相連的。 程序控制器所產(chǎn)生的信號許多只需直接連接到 AT89C51, 無需緩沖。應(yīng)用程序固件響應(yīng)中斷顯示一條消息,關(guān)閉顯示控制線。在編程和程序驗(yàn)證時,編程受端口 0 和端口 2 的一部分控制。由于應(yīng)用程序不使用外部程序存儲器, EA/VPP 腳接 VCC 電源。這種模式與常常在股票價格的顯示器所使用的方法類似。 輸出端口 如果應(yīng)用的電路可以允許端口在編程過程中的狀態(tài)變化,則不需要改變電路。應(yīng)該提供一種方法使得電路通入電源以后,使 RST 代替主要的復(fù)位電路起到復(fù)位的作用 。 它 為電路編程提出 了 相應(yīng)的例子, 程序的修改需要 在線編程 的支持 。此應(yīng)用軟件可以到 Atmel 進(jìn)行下載 。 在編程過程中, AT89C51 的 I / O 端口是用于模式應(yīng)用程序,地址和數(shù)據(jù)選擇的,可能需要該控制器從應(yīng)用的電路隔離。 應(yīng)用實(shí)例 此應(yīng)用程序有在電路重新編程時將結(jié)果以圖表的形式顯示的簡單能力。可顯示字符的 ASCII 碼,范圍為 20H5FH。 編程器的編程需要獲得所有數(shù)據(jù)表中記錄的 AT89C51 的 I / O 端口。鎖存持有的顯示控制信號在編程過程中不反應(yīng),從而消除端口 0 和 2 由于程序控制器的活 動造成操作失誤。雖然這個應(yīng)用程序是沒有必要的,它可能在某些 應(yīng)用中必須指出,在編程過程中不會擾亂外圍電路的狀態(tài)。示例應(yīng)用程序在這種環(huán)境下可正常運(yùn)行。 本地配置 測試配置的本地配置包括一臺 IBM 個人電腦級的計(jì)算機(jī)連接到與 Hayes 兼容的,普羅米修斯 1200 波特的調(diào)制解調(diào)器。 FTP 模式發(fā)送和接收的是用數(shù)字 4 和 5,如流程圖所示。 程序控制器可能通過發(fā)送一個 CAN 來響應(yīng)數(shù)據(jù)包, CAN 表明一個不可恢復(fù)的錯誤發(fā)生,而 發(fā)射機(jī)應(yīng)立即中止文件傳輸。由于 AT89C51的編程和擦除時間可以很容易地吸收, FTP 發(fā)送和等待的性質(zhì)允許跨包延遲。新的程序就被下載并嵌入到應(yīng)用程序中的 AT89C51 的編程。上電時,程序控制器判定 DTR,斷定為 DTR 后調(diào)制解調(diào)器響應(yīng)。在復(fù)位延遲時間傳入是被忽略的。這包類型對程序控制器具有特殊的意義,如下所述。 當(dāng)接收到第一個和其后的有效數(shù)據(jù)程序包時,將它們分開,它們包含的數(shù)據(jù)被編程到程序包負(fù)載地址域中的地址中的應(yīng)用控制器內(nèi)。這樣做將要求錯誤被糾正之前,編程器中的記憶程序被徹底抹掉,造成先前所有數(shù)據(jù)的不可恢