June 2007 Chinese Journal of Scientific Instrument V01.28 No.7 1 AT89C51 In-Circuit Programming Jiang Youl,Tian Dil,Fang Xian92,Zhao Dongzhi3 (J College of Instrument Science&Electrical Engineering,Jilin University,Changchun 130026,China; 2 National Institute of Metrology P.R.China,Beijing 100013, China; 3 Institute of Geology and Geophysics,Chinese Academy of Sciences,Beijing 100029,China) Abstract:Using MCS5 1 series single—chip microcomputer as CPU,a mainboard was designed,which implements most functions of 8一 bit PCI04 bus and has an ethernet interface.Combined with commercial PCI04 bus interface modules,an entire test and control system was constructed.Compared with standard PC 1 04 mainboard based X86 CPU,the proposed mainboard features simple development and application,lower cost, and is suitable for the design and development of low speed control systems.The developed mainboard and system were applied in the control sys—tem of ZDZ mass spectrometer.The trend of the technology is to develop advanced PCI04 mainboard based a 32一 bit microcontroller. Key words: microcontroller; ethernet; embedded system; measurement&control system; 1 Epigraph This application note illustrates the in-circuit programmability of the Atmel AT89C51 Flash-based microcontroller. Guidelines for the addition of in-circuit programmability to AT89C51 applications are presented along with an application example and the modifications to it required to support in-circuit programming. A method is then shown by which the AT89C51 microcontroller in the application can be reprogrammed remotely, over a commercial telephone line. The circuitry described in this application note supports five volt programming only, requiring the use of an AT89C51. The standard AT89C51 requires 12 volts for programming. The software for this application may be obtained by downloading from Atmel’s. Circuitry added to support AT89C51 incircuit programming should appear June 2007 Chinese Journal of Scientific Instrument V01.28 No.7 2 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. 2 Programming 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 three-stated 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. 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. 3 The AT89C51 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 in-circuit 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 four-position DIP switch. In the first mode, one character at a time enters the display from June 2007 Chinese Journal of Scientific Instrument V01.28 No.7 3 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, four-digit, 。