外文翻譯--單片機(jī)在編程電路中的應(yīng)用_第1頁
已閱讀1頁,還剩14頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、<p><b>  附 錄</b></p><p><b>  附錄A 外文資料</b></p><p>  AT89C51 In-Circuit Programming</p><p>  This application note illustrates the in-circuit programmabil

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

3、 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 applicat&

4、lt;/p><p>  General Considerations</p><p>  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. A

5、pplications utilizing external program memory require that this pin be held low during normal operation. </p><p>  RST must be held active during programming. A means must be provided for overriding the appl

6、ication reset circuit, which typically asserts RST only briefly after power is applied.</p><p>  PSEN must be held low during programming, but must not be driven during normal operation.</p><p>

7、  ALE/PROG is pulsed low during programming, but must not be driven during normal operation.</p><p>  During programming, AT89C51 I/O ports are used for the application of mode select, addresses and data, po

8、ssibly 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.</p><p>  Port Used for Input</p

9、><p>  During 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 contro

10、ller, 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 circuitr

11、y or the programmer circuitry.</p><p>  Port Used for Output</p><p>  No circuit changes are required if the application circuitry can tolerate the state changes which occur at the port during p

12、rogramming. 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,

13、preserving the state of the application circuitry. </p><p>  An Application Example</p><p>  This application was selected for its simplicity and ability to show graphically the results of in-ci

14、rcuit reprogramming. The text to be displayed is programmed into the controller as part of its firmware, and cannot be changed without reprogramming the device.</p><p>  The displayed text is presented in on

15、e 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 each element of the display to its final positio

16、n 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

17、of stock prices.</p><p>  The output consists of four DL1414T, four-digit, 17-segment alphanumeric displays with integral decoders and drivers. This yields 16 total display elements, each capable of displayi

18、ng digits 0-9, the upper case alphabet, and some punctuation characters. The displayable character codes are ASCII 20H-5FH.</p><p>  A power-on reset circuit and a 6-MHz crystal oscillator complete the appli

19、cation. Neither external program memory nor external data memory is used.</p><p>  Modifications to the Application to Support</p><p>  In-Circuit Programming Figure 2 shows the application modi

20、fied for in-circuit programming. </p><p>  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 conn

21、ected to VCC. This meets the requirement for programming.</p><p>  The reset circuit has been modified by the addition of two transistors, which allow RST on the controller to be forced high by the programme

22、r.</p><p>  PSEN and ALE/PROG, unused in the basic application, are under the direct control of the programmer.</p><p>  Programming requires programmer access to all of the four AT89C51 I/O por

23、ts, 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 explaine

24、d in the following paragraphs. </p><p>  The least significant four bits of the address generated by the programmer are multiplexed onto port one of the controller with the data from the DIP switch. Note tha

25、t the four resistors added at the switch are not required in the basic application, since the AT89C51 provides internal pull-ups on port one.</p><p>  During the normal operation of the application, controll

26、er 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 conn

27、ected to ports zero and two without buffering, since, when inactive, its presence does not affect the normal operation of the application.</p><p>  A transparent latch has been added between port two of the

28、controller and the display control inputs. The latch holds the display control signals inactive during programming, which eliminates erratic operation of the displays due to programmer activity on ports zero and two. No

29、isolation of the display data inputs is required, since data applied to the inputs is ignored when the control signals are inactive.</p><p>  The AT89C51 reset circuit, input multiplexer and output latch are

30、 controlled by a single signal generated by the programmer. During programming, reset is asserted, the multiplexer switches inputs, and the latch freezes the display control lines.</p><p>  To ensure that th

31、e 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 application before asserting reset. The application firmware responds to t

32、he interrupt by displaying a message and deactivating the display control lines.</p><p>  After programming, when reset is deasserted, the controller ports are high as the latch becomes transparent. Since th

33、e display control inputs are inactive 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 th

34、e state of the peripheral circuitry not be disturbed during programming.</p><p>  The Programmer</p><p>  The programmer (Figure 3) generates the addresses, data and control signals necessary to

35、 program the AT89C51 embedded in the application. </p><p>  The programmer circuitry consists of an AT89C51 and an RS-232 level translator. The controller runs at 11.0592 MHz, which allows the serial port to

36、 operate at a number of standard baud rates. A Maxim MAX232 line driver/receiver produces RS-232 levels at the serial interface while requiring only a five volt supply.</p><p>  Many of the signals generated

37、 by the programmer are connected directly, without buffering, to the AT89C51 in the application. These signals, when inactive, are not threestated, but are pulled high. The AT89C51 has internal pull-ups of approximately

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

39、perates correctly in this envir</p><p>  The AT89C51 in the programmer does not utilize external program or data memory, which would require sacrificing needed I/O pins. This requires that program code and I

40、/O buffers be kept small enough to fit in on-chip memory.</p><p>  Remote Programming Over a CommercialTelephone Line</p><p>  The programmer and display application described previously are con

41、nected to a phone line via a modem at a remote site. Using a personal computer with a modem, a user can upload a new program containing a new message, which is programmed into the AT89C51 embedded in the application. Whe

42、n programming is complete, the application executes the new program, which displays the new message.</p><p>  Local Station</p><p>  The local station in the test configuration consists of an IB

43、M PC AT-class 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 transmiss

44、ion time is reduced below one minute, further reductions in transmission time do not further reduce connect time charges. A possible advantage to higher transmission speeds is the automatic error detection and correctio&

45、lt;/p><p>  Procomm Plus version 2.01, a commercial data communications package, is used to configure the modem, set up communications parameters, and establish a link with the remote modem. Procomm Plus includ

46、es 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 i

47、t to the remote programmer.</p><p>  The file transfer protocol (FTP) implemented is a simple send-and-wait, packet-oriented protocol. The trans mit and receive modes of the FTP are illustrated by the flowch

48、arts 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 cal

49、culated checksum is valid, the programmer acknowledges the packet by sending an ACK. If the checksum is in err</p><p>  The programmer might respond to a packet by sending a CAN, which indicates that a non-r

50、ecoverable 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 pack

51、et. 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. A</p><p>  Afte

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

53、programming fails, the programmer sends CAN to signal the transmitter to abort the file transfer.</p><p>  The simplicity of the FTP reduces the amount of AT89C51 program memory used in the programmer. The s

54、end-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 a

55、dditional data transfers.</p><p>  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 M

56、CS-51 Macro Assembler, MCS-51 Relocator and Linker, and a useful utility, OH. OH converts an absolute 8051 object file to an equivalent ASCII hexadecimal object file.</p><p>  The records in the hex file pro

57、duced by the OH utility serve, unchanged, as the packets in the FTP described above; no service fields need to be added. The colon which begins each record serves as the packet signature field. The load address field ser

58、ves as the packet sequence number. A checksum is provided as the last field in each record. Since seven-bit ASCII coding is utilized, the eighth bit of each byte is available to be used for parity checking.</p>&l

59、t;p>  Because the AT89C51 in the programmer does not utilize external data memory, necessary packet buffering must be done using internal RAM. Limited memory precludes the use of conventional FTPs which utilize packet

60、s of 128 bytes and larger. The hex packet format used in this application limits packet data fields to 16 or fewer entries, requiring little memory for buffering.</p><p>  The ready availability of a utility

61、 for creating the packetized program file, combined with small packet size and adequate error checking, makes the hex packet format a near ideal solution for this application. A disadvantage is the use of ASCII, which re

62、quires each program data byte to be expressed as two hex characters. This demands that nearly twice as many bytes be transferred as might otherwise be required. This is not a severe limitation, however, since typical fil

63、e transfer times are less</p><p>  Remote Station</p><p>  The remote station in the test configuration consists of the display application and programmer circuits, described previously, connect

64、ed to a Hayes-compatible, Prometheus 1200 baud modem. During normal operation, the application executes its internal program while the modem and programmer monitor the phone line for incoming calls.</p><p> 

65、 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 embedded in the

66、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.</p><p>  The programmer

67、 powers up with its programming control outputs inactive, allowing the application to run normally. After configuring the modem to answer incoming calls, the programmer puts itself to sleep. The programmer will not distu

68、rb the application until a new program is to be downloaded.</p><p>  The programmer controls the modem by sending ASCII command strings over the serial interface, to which the modem responds with Hayes-style

69、 ASCII numeric codes. The software is designed for use with Hayes-compatible modems, which includes the Prometheus ProModem 1200 used here.</p><p>  The serial interface, through which the programmer connect

70、s to the modem, supports two handshaking signals, DTR and DSR. On power up, the programmer asserts DTR, to which the modem responds by asserting DSR. If the modem should fail to respond to any command, including the comm

71、and to hang up, the programmer deasserts DTR, which forces the modem to drop the line.</p><p>  The modem monitors the phone line while the programmer sleeps, waiting for an incoming call. When a call is det

72、ected, 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 begin

73、s polling for a valid packet header.</p><p>  Incoming 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 ca

74、ll. If the caller hangs up, the thirty second period must expire before another call will be answered. Calls incoming during the reset delay period are ignored.</p><p>  If a valid packet header is received

75、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 timeout during character

76、 reception will cause the partial packet to be declared invalid and discarded.</p><p>  Two packet types are defined: data and end-of-file. A data packet contains five fields in addition to the packet header

77、, one of which is a variable length data field. The data field contains program data to be written into the AT89C51 controller in the application. The load address field contains the address at which the data is to be wr

78、itten. The end-of-file packet contains the same fields as the data packet, except that the data field is empty. This packet type has special meaning to the progr</p><p>  Any packet which contains an invalid

79、 record type, record length or checksum is invalid. Program data accumulated during the processing of an invalid packet is discarded. The programmer sends a NAK to the transmitter to signal reception of an invalid packet

80、 and resumes polling for a valid packet header.</p><p>  Receipt of the first valid data packet causes the programmer to interrupt the application controller. The controller responds to the interrupt by aban

81、doning execution of its usual program and displaying a message indicating that programming is taking place. If this is the first valid data packet since power was applied or an end-of-file packet was received, the progra

82、mmer asserts the control signals necessary to erase the program memory in the application controller. The programmer then places t</p><p>  The first and subsequent valid data packets are dissected as they a

83、re received and the data which they contain is programmed into the application controller at the address indicated in the packet load address field. After programming, the data is read back from the controller and verifi

84、ed against the received packet data. Successful verification indicates that programming was successful, causing the programmer to send ACK to the transmitter. The programmer then resumes polling for a valid packet</p&

85、gt;<p>  If programming fails, the programmer sends CAN to signal the transmitter to abort the file transfer. The modem drops the line and the programmer returns to sleep, waiting for the next call. The applicatio

86、n controller is left in programming mode, preventing it from executing the incomplete or invalid program which it contains.</p><p>  It is important to note that invalid packets are NEVER programmed into the

87、 application controller. To do so would require that the program memory in the controller be completely erased before the error could be corrected, causing the non-recoverable loss of all previous program data.</p>

88、<p>  Upon receipt of an end-of-file packet, the programmer returns its control outputs to the inactive, power on state, allowing the application controller to begin execution of the new program. The programmer th

89、en resumes polling for a valid packet header, subject to the thirty second reset delay.</p><p>  If a valid packet is received prior to the expiration of the thirty second delay, another programming cycle be

90、gins, which can only be terminated by the reception of a valid end-of-file packet.</p><p>  If the reset delay expires prior to the reception of a valid end-of-file packet, the modem will drop the line and t

91、he programmer will return to sleep, waiting for the next call. In this case, the application controller is left in programming mode, preventing it from executing its program. To return the application to normal operation

92、, another call must be received, and a valid program file uploaded, terminated by an end-of-file packet.</p><p>  單片機(jī)在編程電路中的應(yīng)用</p><p>  本應(yīng)用指南說明了Atmel AT89C51是可在線可編程的微控制器。它為電路編程提出了相應(yīng)的例子,程序的修改需要在線

93、編程的支持。這類顯示方法在應(yīng)用程序中的AT89C51單片機(jī)可通過電話線遠(yuǎn)程控制。該應(yīng)用指南所描述的電路只支持5v電壓下編程。此應(yīng)用軟件可以到Atmel進(jìn)行下載。</p><p><b>  總論</b></p><p>  在編程期間必須重視EA/VPP這一腳。在不使用外部程序存儲(chǔ)器的應(yīng)用程序中,這腳可能會(huì)永久接到VCC。應(yīng)用程序使用的外部程序存儲(chǔ)器要求這一腳為低電平

94、才能正常運(yùn)行。</p><p>  RST在編程期間必須為高電平。應(yīng)該提供一種方法使得電路通入電源以后,使RST代替主要的復(fù)位電路起到復(fù)位的作用 。</p><p>  在編程過程中,PSEN必須保持低電平,在正常運(yùn)行期間絕不能使用。</p><p>  ALE/ PROG在編程過程中輸出低電平,在正常運(yùn)行期間絕不能使用。</p><p> 

95、 在編程過程中,AT89C51的I / O端口是用于模式應(yīng)用程序,地址和數(shù)據(jù)選擇的,可能需要該控制器從應(yīng)用的電路隔離。如何做到這一點(diǎn)取決于應(yīng)用程序。</p><p><b>  輸入端口</b></p><p>  在編程過程中,控制器必須與應(yīng)用電路的信號(hào)來源隔離。帶有三個(gè)輸出狀態(tài)的緩沖區(qū)會(huì)在應(yīng)用程序之間插入電路和控制器,同時(shí)在編程時(shí)緩沖區(qū)輸出三種狀態(tài)。一個(gè)多路復(fù)用器

96、可用于信號(hào)源之間進(jìn)行選擇,適用于任何一方的應(yīng)用電路或編程控制器電路的信號(hào)。</p><p><b>  輸出端口</b></p><p>  如果應(yīng)用的電路可以允許端口在編程過程中的狀態(tài)變化,則不需要改變電路。如果應(yīng)用電路的狀態(tài)不變化,必須事先在編程過程中的保持不變,可能在控制器和應(yīng)用電路中插入鎖存。鎖存在編程期間是可用的,并保存應(yīng)用程序的電路狀態(tài)。</p>

97、;<p><b>  應(yīng)用實(shí)例 </b></p><p>  此應(yīng)用程序有在電路重新編程時(shí)將結(jié)果以圖表的形式顯示的簡單能力。文本顯示被設(shè)計(jì)作為其硬件的一部分,不能在無改編情況下變化。</p><p>  顯示的文本可在4位DIP開關(guān)選擇兩種模式之一中進(jìn)行。在第一種模式的時(shí)候,進(jìn)入一個(gè)字符從右邊顯示和快速移動(dòng),通過每個(gè)元素顯示其在最后的裝配位置的左側(cè)。

98、在第二個(gè)模式,信息在信息窗口中右到左移動(dòng)顯示。這種模式與常常在股票價(jià)格的顯示器所使用的方法類似。</p><p>  輸出包括四個(gè)DL1414T,4位17段的積分解碼器和驅(qū)動(dòng)程序的字母數(shù)字顯示器。這就產(chǎn)生了16名顯示元素,每個(gè)數(shù)字有0-9的顯示能力,是大寫字母,標(biāo)點(diǎn)符號(hào)和一些字符。可顯示字符的ASCII 碼,范圍為20H-5FH。上電復(fù)位電路和一個(gè)6 MHz的晶體振蕩器完成應(yīng)用軟件程序。無論外部程序存儲(chǔ)器或外部數(shù)

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論