单片机C51在线编程中英文翻译.doc

上传人:豆**** 文档编号:17506623 上传时间:2022-05-24 格式:DOC 页数:13 大小:257.50KB
返回 下载 相关 举报
单片机C51在线编程中英文翻译.doc_第1页
第1页 / 共13页
单片机C51在线编程中英文翻译.doc_第2页
第2页 / 共13页
点击查看更多>>
资源描述

《单片机C51在线编程中英文翻译.doc》由会员分享,可在线阅读,更多相关《单片机C51在线编程中英文翻译.doc(13页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流单片机C51在线编程中英文翻译.精品文档.英文原文:AT89C51 In-Circuit Programming 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

2、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

3、 five volt programming only, requiring the use of an AT89C51-XX-5. The standard AT89C51 requires 12 volts for programming. The software for this application may be obtained by downloading from Atmels General Considerations Circuitry added to support AT89C51 incircuit programming should appear transp

4、arent 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 duri

5、ng 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

6、 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 dep

7、endent and will be addressed here only in general terms.Port Used for InputDuring programming, the controller must be isolated from signals sourced by the application circuitry. A buffer with three state outputs might be inserted between the application circuitry and the controller, with the buffer

8、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.Port Used for OutputNo circuit changes are required if the application c

9、ircuitry 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, preservi

10、ng the state of the application circuitry. An Application ExampleThe AT89C51 application 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

11、 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 the right and moves quickly to the left through

12、 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 cons

13、ists of four DL1414T, four-digit, 17-segment alphanumeric displays with integral decoders and drivers. This yields 16 total display elements, each capable of displaying digits 0-9, the upper case alphabet, and some punctuation characters. The displayable character codes are ASCII 20H-5FH.Modificatio

14、ns to the Application to SupportIt 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 ci

15、rcuit has been modified by the addition of two transistors, which allow RST on the controller to be forced high by the programmer. PSEN and ALE/PROG, unused in the basic application, are under the direct control of the programmer.Programming requires programmer access to all of the four AT89C51 I/O

16、ports, as documented in the data sheet. The programmer is connected directly to those controller pins which are unused by the application, while access to pins used by the application requires special treatment, as explained in the following paragraphs. The least significant four bits of the address

17、 generated by the programmer are multiplexed onto port one of the controller with the data from the DIP switch. Note that the four resistors added at the switch are not required in the basic application, since the AT89C51 provides internal pull-ups on port one.During the normal operation of the appl

18、ication, controller ports zero and two provide data and control signals (respectively) to the displays. During programming and program verification, the programmer asserts control of port zero and part of port two. The programmer is connected to ports zero and two without buffering, since, when inac

19、tive, its presence does not affect the normal operation of the application.A transparent latch has been added between port two of the controller and the display control inputs. The latch holds the display control signals inactive during programming, which eliminates erratic operation of the displays

20、 due to programmer activity on ports zero and two. No isolation of the display data inputs is required, since data applied to the inputs is ignored when the control signals are inactive.The AT89C51 reset circuit, input multiplexer and output latch are controlled by a single signal generated by the p

21、rogrammer. During programming, reset is asserted, the multiplexer switches inputs, and the latch freezes the display control lines.To ensure that the display control lines are in a known state before they are latched, an AT89C51 external interrupt is used to allow the programmer to signal the applic

22、ation before asserting reset. The application firmware responds to the interrupt by displaying a message and deactivating the display control lines.After programming, when reset is deasserted, the controller ports are high as the latch becomes transparent. Since the display control inputs are inacti

23、ve high, the display contents are not disturbed until the new program writes the display. Although not essential to this application, it might be imperative in some applications that the state of the peripheral circuitry not be disturbed during programming.The ProgrammerThe programmer generates the

24、addresses, data and control signals necessary to program the AT89C51 embedded in the application. The programmer circuit consists of an AT89C51 and an RS-232 level translator. The controller runs at 11.0592 MHz, which allows the serial port to operate at a number of standard baud rates. A Maxim MAX2

25、32 line driver/receiver produces RS-232 levels at the serial interface while requiring only a five volt supply.Many of the signals generated by the programmer are connected directly, without buffering, to the AT89C51 in the application. These signals, when inactive, are not three stated, but are pul

26、led high. The AT89C51 has internal pull-ups of approximately three Kohms on ports one, two and three. Because port zero does not have internal pull-ups, external pull-ups of ten Kohms have been added to permit proper operation of program verification mode. The sample application operates correctly i

27、n this environment. If required for compatibility with an application, programmer signals may be buffered with three-state buffers similar to the 74xx125.The AT89C51 in the programmer does not utilize external program or data memory, which would require sacrificing needed I/O pins. This requires tha

28、t program code and I/O buffers be kept small enough to fit in on-chip memory.Remote Programming Over a Commercial Telephone LineThe programmer and display application described previously are connected to a phone line via a modem at a remote site. Using a personal computer with a modem, a user can u

29、pload a new program containing a new message, which is programmed into the AT89C51 embedded in the application. When programming is complete, the application executes the new program, which displays the new message.Local StationThe local station in the test configuration consists of an IBM PC AT-cla

30、ss computer connected to a Hayes-compatible, Prometheus 1200 baud modem. The modem was selected because it was inexpensive and available. A faster modem may be used if desired, although once the file transmission time is reduced below one minute, further reductions in transmission time do not furthe

31、r reduce connect time charges. A possible advantage to higher transmission speeds is the automatic error detection and correction available in some high speed modems.Procomm Plus version 2.01, a commercial data communications package, is used to configure the modem, set up communications parameters,

32、 and establish a link with the remote modem. Procomm Plus includes a macro language called ASPECT, which allows the user to write and compile scripts which implement custom file transfer protocols. A simple ASPECT script was written to read the contents of a program file and upload it to the remote

33、programmer.The file transfer protocol (FTP) implemented is a simple send-and-wait, packet-oriented protocol. The transmit 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.

34、The programmer (the receiver) reads and dissects the packet while calculating a checksum. If the calculated checksum is valid, the programmer acknowledges the pack by sending an ACK. If the checksum is in error, the programmer negatively acknowledges the pack by sending a NAK. Upon receipt of an ACK

35、, 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 non-recoverable error has occurred

36、 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 a

37、llowed 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 controlle

38、r 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

39、amount of AT89C51 program memory used in the programmer. The send-and-wait nature of the FTP allows inter-packet delays due to AT89C51 program and erase times to be easily absorbed. Support for program verification is transparent, requiring no explicit command or result codes, or additional data tra

40、nsfers.The files which are uploaded to the programmer are created with the tools in the Intel MCS-51 Software Development Package for the IBM PC. Included in the package are the MCS-51 Macro Assembler, MCS-51 Relocator and Linker, and a useful utility, OH. OH converts an absolute 8051 object file to

41、 an equivalent ASCII hexadecimal object file.Remote StationThe remote station in the test configuration consists of the display application and programmer circuits, described previously, connected to a Hayes-compatible, Prometheus 1200 baud modem. During normal operation, the application executes it

42、s internal program while the modem and programmer monitor the phone line for incoming calls.After a call has been detected and a connection established, the programmer forces the application to suspend execution of its program. The new program is then downloaded and programmed into the AT89C51 embed

43、ded in the application. When programming is complete, the application is allowed to begin execution of its new program, and the programmer returns to monitoring the phone line for the next call.The programmer powers up with its programming control outputs inactive, allowing the application to run no

44、rmally. After configuring the modem to answer incoming calls, the programmer puts itself to sleep. The programmer will not disturb the application until a new program is to be downloaded.The programmer controls the modem by sending ASCII command strings over the serial interface, to which the modem

45、responds with Hayes-style ASCII numeric codes. The software is designed for use with Hayes-compatible modems, which includes the Prometheus ProModem 1200 used here.The serial interface, through which the programmer connects to the modem, supports two handshaking signals, DTR and DSR. On power up, th

46、e programmer asserts DTR, to which the modem responds by asserting DSR. If the modem should fail to respond to any command, including the command to hang up, the programmer deasserts DTR, which forces the modem to drop the line.The modem monitors the phone line while the programmer sleeps, waiting f

47、or an incoming call. When a call is detected, the modem answers and attempts to establish communication with the caller. If a connection is established, the modem sends a code to the programmer, waking it up. The programmer verifies the connect code and begins polling for a valid packet header.Incom

48、ing packets must arrive fewer than thirty seconds apart, or the modem drops the line (hangs up) and the programmer returns to sleep, waiting for the next call. If the caller hangs up, the thirty second period must expire before another call will be answered. Calls incoming during the reset delay per

49、iod are ignored.If a valid packet header is received prior to the expiration of the reset delay period, the programmer will attempt to read and validate the incoming packet. At any time during packet reception, an invalid character, parity error or time-out during character reception will cause the partial packet to be declared invalid and discarded.Two packet types are defined: data and end-of-file. A data packet contains five fields in addition to the packe

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁