【正文】
含的數(shù)據(jù)被編程到程序包負載地址域中的地址中的應(yīng)用控制器內(nèi)。編程后,從控制器內(nèi)將數(shù)據(jù)讀回并與接收到的數(shù)據(jù)包中的數(shù)據(jù)進行比較。成功的核查表明,方案是成功的,導(dǎo)致編程器向 傳送者發(fā)送 ACK信號。由于 30秒的復(fù)位延遲,編程器重新對有效的數(shù)據(jù)包報頭進行測試。 如果編程失敗,編程器向傳送者發(fā)送信號 CAN中止文件傳輸。調(diào)制解調(diào)器掉線,程序器繼續(xù)休眠等待下一次呼叫。應(yīng)用控制在程序模式中被保留,用以阻止它包含的不完整的或無效的程序。 重要的是要注意,無效的數(shù)據(jù)包永遠不會規(guī)劃到應(yīng)用程序控制器。這樣做將要求錯誤被糾正之前,編程器中的記憶程序被徹底抹掉,造成先前所有數(shù)據(jù)的不可恢復(fù)。 根據(jù)末端文件的接收,編程器向閑置的狀態(tài)電源返回其控制輸出,允許應(yīng)用程序控制器,開始執(zhí)行新的程序。然后編程器在三十 秒延遲之下重新開始對一個數(shù)據(jù)包報進行審查。 如果一個有效的數(shù)據(jù)包在 30秒延遲之前接收,另一個只能被接受一個有效的末端文件而終止的程序循環(huán)開始執(zhí)行。 如果復(fù)位在收有效末端文件之前終止,那么調(diào)制解調(diào)器會掉線,編程器停止工作,等待下一次傳入。在這種情況下應(yīng)用控制器被保留在程序設(shè)計模式,以防止它執(zhí)行這個程序。要返回應(yīng)用程序的正常運行,另一個傳入必須被接收,一個有效的程序文件被上傳,由末端文件包終止。 AT89C51 InCircuit Programming This application note illustrates the incircuit programmability of the Atmel AT89C51 Flashbased microcontroller. Guidelines for the addition of incircuit programmability to AT89C51 applications are presented along with an application example and the modifications to it required to support incircuit programming. A method is then shown by which the AT89C51 microcontroller in the application can be reprogrammed remotely, over a mercial telephone line. The circuitry described in this application note supports five volt programming only, requiring the use of an AT89C51XX5. The standard AT89C51 requires 12 volts for programming. The software for this application may be obtained by downloading from Atmel’s General Considerations Circuitry added to support AT89C51 incircuit programming should appear transparent to the application when programming is not taking place. EA/VPP must be held high during programming. In applications which do not utilize external program memory, this pin may be permanently strapped to VCC. Applications utilizing external program memory require that this pin be held low during normal operation. RST must be held active during programming. A means must be provided for overriding the application reset circuit, which typically asserts RST only briefly after power is applied. PSEN must be held low during programming, but must not be driven during normal operation. ALE/PROG is pulsed low during programming, but must not be driven during normal operation. During programming, AT89C51 I/O ports are used for the application of mode select, addresses and data, possibly requiring that the controller be isolated from the application circuitry. How this is done is application dependent and will be addressed here only in general terms. Port Used for Input During programming, the controller must be isolated from signals sourced by the application circuitry. A buffer with threestate outputs might be inserted between the application circuitry and the controller, with the buffer outputs threestated when programming is enabled. Alternately, a multiplexer might be used to select between signal sources, with signals applied to the controller by either the application circuitry or the programmer circuitry. Port Used for Output No circuit changes are required if the application circuitry can tolerate the state changes which occur at the port during programming. If the prior state of the application circuitry must be maintained during programming, a latch might be inserted between the controller and the application circuitry. The latch is enabled during programming, preserving the state of the application circuitry. An Application Example The AT89C51 application shown in Figure 1 is an implementation of a moving display. This application was selected for its simplicity and ability to show graphically the results of incircuit reprogramming. The text to be displayed is programmed into the controller as part of its firmware, and cannot be changed without reprogramming the device. The displayed text is presented in one of two modes selected by the fourposition DIP switch. In the first mode, one character at a time enters the display from the right and moves quickly to the left through each element of the display to its final position in the assembled message. In the second mode, the message moves through the display, from right to left, with the display acting as a window onto the message. This mode is familiar as the method often used in displays of stock prices. The output consists of four DL1414T, fourdigit, 17segment alphanumeric displays with integral decoders and drivers. This yields 16 total display elements, each capable of displaying digits 09, the upper case alphabet, and some punctuation characters. The displayable character codes are ASCII 20H5FH. A poweron reset circuit and a 6MHz crystal oscillator plete the application. Neither external program memory nor external data memory is used. Modifications to the Application to Support InCircuit Programming Figure 2 shows the application modified for incircuit programming. It is assumed that the programmer, when inactive, will neither drive nor excessively load the application. Since the application does not use external program memory, EA/VPP on the controller is connected to VCC. This meets the requirement for programming. The reset circuit has been modified by the addition of twotransistors, which allow RST on