電氣工程.外文翻譯_第1頁
電氣工程.外文翻譯_第2頁
電氣工程.外文翻譯_第3頁
電氣工程.外文翻譯_第4頁
電氣工程.外文翻譯_第5頁
已閱讀5頁,還剩13頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、理工學院畢業(yè)設計(論文)外文資料翻譯專 業(yè): 電氣工程及其自動化 姓 名: 廉宏揚 學 號: 11L0851084 外文出處: Microcontrollers in Practice 附 件: 1.外文資料翻譯譯文;2.外文原文。 指導教師評語: 簽名: 年 月 日附件1:外文資料翻譯譯文8.3_ 寫一個字節(jié)EEPROM該E2W(EEPROM寫入)子程序,下面列出。假設:E2W LDAB #$02 ; BYTE=O, ERASE=O, EELAT=1STAB PPROG STAA O,X ;寫操作門閂的地址和數(shù)據(jù) LDAB #$03 ;使 EEPGM=1STAB PPROG ;開始Vpp的電

2、荷泵JSR DLY10 ;等待10毫秒CLR PPROG ;停止Vpp的并返回到讀模式RTS ;返回到主程序*在與寫入操作的目標地址相關聯(lián)BPROT所述位被清除,即目的地不是寫保護。*目的地字節(jié)先前已擦除。*目的地字節(jié)的地址被放置在X中*數(shù)據(jù)字節(jié)將被寫入在EEPROM置于A.如果ERASE=1和 BYTE =0,設置PPROG將啟動對整個EEPROM存儲器擦除序列。所謂的批量擦除。閱讀EEPROM寫或擦除操作正在進行中(EELAT = 1)返回錯誤數(shù)據(jù)。沒有硬件機制來防止這種類型的錯誤。8.3.3配置寄存器在CONFIG寄存器由8 EEPROM單元,組織成位于MCU的I / O寄存器塊寄存器。

3、在CONFIG寄存器可以被刪除或者只是像任何其他EEPROM的位置編程,是68HC11F1的CONFIG寄存器的結(jié)構(gòu)如下:*NOCOP= L禁用COP(計算機正常運行)看門狗,*ROMON=1使內(nèi)部ROM。* EEON= L啟用內(nèi)部EEPROM。在HCll組織的一些單元允許EEPROM塊存儲器映射中的任何4K邊界開始重新映射,為了達到這個目的,最顯著四位的配置寄存器,調(diào)用EE3:EE2:EE1:EE用于定義最顯著四個比特EEPROM的地址。例如,如果EE3:EE2:EE1:EE = 0:1:0:1,則對EEPROM的起始地址是$ 5000。 8.4在AVR微控制器的EEPROM存儲器

4、  有在EEPROM存儲器中的AVR微控制器實現(xiàn)的,相比HC11的方式顯著差異。而在HC11,EEPROM存儲器是在存儲器映射中直接可見的,并且可以被用作數(shù)據(jù)存儲器或作為程序存儲器,用于接入到EEPROM看起來更像從外圍接口訪問數(shù)據(jù)的AVR處理器。8.4.1EEPROM作為接口的寄存器四個寄存器控制訪問EEPROM . .這些都是叫EEARH EEARL.EEARL EECR。* EEARH - EEARL(EEPROM地址)一起形成一個16位寄存器實現(xiàn)EEPROM地址空間。* EEDR-EEPROM數(shù)據(jù)寄存器。這是用于訪問EEPROM數(shù)據(jù), 在讀取和寫入操作。* EECR

5、-EEPROM控制寄存器包含了控制位的讀寫操作。EECR具有以下結(jié)構(gòu)。 * EEMWE-EEPROM主允許寫入。這一點EEPROM數(shù)據(jù)提供了一種保護機制,在項目失控。EEMWE由軟件設定,但是是由硬件自動清除,在四個主要系統(tǒng)時鐘周期。在這四個周期的間隔,可以啟動EEPROM寫操作,通過編寫EEWE 1。試圖寫入EEWE EEMWE = 0時無效果。當電源電壓EEWE是通過硬件。因此,建議調(diào)查EEWE,決定寫操作結(jié)束。* EERE-EEPROM讀啟用,這一點選擇的訪問類型EEPROM,EERE = 1表示一個讀操作,而EERE = 0表示寫操作。8.4.2軟件Routones讀取和寫入EEPRO

6、M讀一個字節(jié)從EEPROM通過測試EEWE在R16的下列程序序列中讀取從由寄存器Z的指示的地址它啟動一個EEPROM字節(jié),以確定該接口已經(jīng)準備好.如果 EEWE=0, Z的內(nèi)容被傳輸?shù)紼EARH-EEARL,則控制世界寫入EECR有EERE=1(讀操作)。該EEPROM數(shù)據(jù)現(xiàn)在可讀EEDR。 EERead: SBIC EECR,EEWE ;確保 EEWE=0 RJMP EERead OUT EEARH,ZH ;在 EEARH-EEARL寫地址 OUT EEARL,ZL LDI R16,$01 ;EERE=1 - 讀操作 OUT EECR,R16 IN R16,EEDR ;讀 R1

7、6數(shù)據(jù) RET寫一個字節(jié)EEPROM下面描述的子程序?qū)懙街付ǖ淖止?jié)在R16EEPROM地址。執(zhí)行下列操作順序:l*檢查EEWE確定接口是否準備好了。l*寫Z EEARH:EEARL。l*寫R16 EEDR。l*EEWME設置。l*EEWE開始實際的寫操作。這是程序,執(zhí)行這些操作;EEWrite: SBIC EECR,EEWE ;確保 EEWE=0 RJMP EEWrite OUT EEARH,ZH ;在 EEARH-EEARL寫地址 OUT EEARL,ZL OUT EEDR,R16 ;數(shù)據(jù)寫入 EEDR CLI ;禁止中斷 LDI R16,$O4 ;EEMWE=1 OUT EE

8、CR,R16 LDI R16,$02 ;EEWE=1 OUT EECR,R16 SEI ;允許中斷 RET 不是啟動實際寫入命令之前,該程序禁用所有interrupts.The原因是,步驟4執(zhí)行和5之間發(fā)生會耽誤時EEWE設置超出四個周期的極限的時刻中斷EEMWE置后。在步驟5中寫入EEWE會發(fā)現(xiàn)由硬件EEWME清零,整個的寫操作將失敗9.1在本章本章包含的描述一個簡單的基于68 hc11f1單片機開發(fā)板。和相關軟件工具,主要以允許用戶編寫和測試軟件應用單片機。9.2描述的硬件模塊對于微控制器的研究開發(fā)系統(tǒng)包括硬件模塊和一組軟件實用程序(交叉匯編器,編譯器等)與來自制造商的數(shù)據(jù)表和應用筆記。隨

9、著,這使用戶可以達到一個清晰的認識的資源和該特定的微控制器的能力,并編寫和測試軟件應用程序。本文提供的模塊是最簡單的一個可能的。它是建立在摩托羅拉68 hc11f1單片機,操作與外部EEPROM作為AT28C256,輕易可重復編程的10000倍左右。可以編寫測試程序直接使用標準的商業(yè)AT28C256 EPROM程序。68年hc11f1單片機劑量沒有內(nèi)部程序內(nèi)存它是為了工作與外部ROM擴展模式。為此,單片機可以提供四個芯片選擇信號外部內(nèi)存或I / O設備。這些信號激活的方式,他們的極性和相對優(yōu)先級軟件控制。硬件模塊的原理提出了Fig.9.1。有極少的外部元件,除了微控制器。程序存儲器被直接連接到

10、所述地址和數(shù)據(jù)總線,ANF芯片選擇信號CSPROG由微控制器提供,而無需外部地址譯碼器。外部時鐘電路是使用晶體Q1(8兆赫典型),電容C5和C6(15-22pF)和電阻器R1(為1-10m)來實現(xiàn)。這種類型的振蕩電路是典型的HC11的所有家庭成員。復位電路包括連同電阻R2,R3,R4 capacitorC9和連接器JP1晶體管T1。在上電時,電容器C8開始通過R2充電,供給到T1.這個基極電流飽和晶體管的時間間隔可比R28C9,產(chǎn)生一個低電平有效脈沖在微控制器的RESET線。當JP1的端子短路時,發(fā)生類似的過程,這是模塊的手動復位的手段。C2的電路(MAX232)連同電容器C1,C2,C3和C

11、4的實施呈現(xiàn)的典型RS232接口??刂菩盘朚ODB和外部中斷IRQ和XIRQ使用10 k電阻。測試單片機的I / O線被帶到三個為header類型的連接器SV1 SV2.SV3。模塊驅(qū)動的直流或交流適配器, 能夠提供9-12V電流為250mA供電。通過橋式整流器輸入電壓B1的電壓調(diào)節(jié)器IC4(7805)產(chǎn)生的+ 5 v電源電壓。9.3組裝和測試模塊所有的項目。本節(jié)中的配有詳細的原理圖和印刷電路板的圖紙上可用所附CD. PCB的附圖描述與4.11從CadSoft公司創(chuàng)建的。該軟件的免費版本可以從CadSoft公司免費下載,使用戶可以查看,編輯和打印所有的原理圖,在這本書中描述的項目的PCB圖。這

12、種CAD軟件的主要優(yōu)點是,這是很容易學習,和免費軟件版本,盡管有一些限制,仍允許用戶設計相當復雜的基于微控制器的電路。大多數(shù)公司制造的定制印刷電路板接受鷹4.11中創(chuàng)建的圖紙,每印刷電路板平方分米的成本是合理的。然而,在這個特殊的情況下,該電路是如此簡單,它可以容易地實現(xiàn)關于使用導線纏繞技術中的原型板。建議使用合適的IC插座的所有芯片,除了IC4。參照圖9.2用于PCB的一個可能的組件布局。    一旦你的模塊組裝。按照這個測試序列:1.應用能力模塊。而不必在插座插入集成電路。2.檢查+5 V電壓上的每個插槽。3.通過測量電壓在T1的集電極,當短路被施加

13、到JPI的終端檢查復位電路。在這一點上的電壓下降到接近0V。而沒有短路它保持接近V值。4.將芯片插入插座,接通電源模塊。用示波器檢查引腳40F單片機電子時鐘。如果沒有一個示波器,使用電壓表來測量T1的集電極的RESET信號。如果振蕩器不能操作,微控制器的時鐘監(jiān)控電路將迫使該行邏輯0。5.如果一切都是好的,安裝cross-assembler,描述在接下來的段落和組裝一個簡單的軟件的例子,像介紹X9.1的這一章。6.使用一個商業(yè)EPROM程序,程序AT28C256內(nèi)存cross-assembler創(chuàng)建的二進制文件,并檢查模塊的預期行為。9.4描述的軟件組件免費軟件交叉匯編摩托羅拉的HC11系列提供

14、的。所謂AS11.EXE,是非常簡單的,有許多不足之處。其中,最重要的是:它不允許INCLUDE指令,從而迫使用戶寫在一個文件中的所有的源代碼。這可以是非常好的.例如,摩托羅拉(BUFFALO)提供的免費顯示器的源代碼有超過5000行代碼。很顯然,這幾乎是不可能調(diào)試這樣一個程序,如果有什么不順心。另一方面,如果匯編包括INCLUDE,源代碼可被組織在較小的,可重復使用。的代碼塊。放置在不同的文件中,根據(jù)一些用戶選擇的標準,例如TIMER.ASM,SCI.ASM,OUTPUT.ASM,等等。所有這些軟件模塊由一個主模塊調(diào)用,使用INCLUDE指令。*它不允許宏定義,從而嚴重地限制了用戶的自由定制

15、他/她的編程環(huán)境。由于這些原因,我們選擇使用不同的免費交叉匯編,被稱為ASHC11,由彼得·加爾加諾創(chuàng)建。除了INCLUDE和宏定義,這種交叉匯編有許多額外的功能。請參閱附錄B2關于如何下載這個軟件的詳細信息。入門第一步,安裝交叉匯編ASHC11是DOS應用,并且不需要任何特殊的安裝過程。 ASHC1l:要安裝它,硬盤驅(qū)動器的名稱C上創(chuàng)建一個文件夾。并解壓縮下載的存檔到這個文件夾。然后創(chuàng)建一個DOS窗口。其工作目錄中的C: ASHCl。要做到這一點,在Windows9.x中按下鼠標的右按鈕的桌面上,并且,從呈現(xiàn)選項列表。選擇新建。那么快捷方式。在預留空間來定義關聯(lián)到新的快捷方式的命令

16、行。鍵入“命令.COM”,然后按Next按鈕。和完成。      這個操作的效果是一個新出現(xiàn)的快捷方式命名為“MS-DOS方式”在桌面上。要完成這項工作。指定該工作目錄。附件2:外文原文8.3_ Wdting a Byte to EEPROMThe E2W (EEPROM write) subroutine,listed below. assumes that:E2W LDAB #$02 ; BYTE=O, ERASE=O, EELAT=1STAB PPROG STAA O,X ;write operation to latch th

17、e ; address and dataLDAB #$03 ;make EEPGM=1STAB PPROG ;start Vpp charge pumpJSR DLY10 ;wait 10 msCLR PPROG ;stop Vpp and return to read ; modeRTS ;return to main program * The bit in BPROT associated with the destination address of the write operation is cleared, i.e. the destination is not write pr

18、otected. * The destination byte has been previously erased.* The address of the destination byte is placed in X.* The data byte to be written in the EEPROM is placed in A. If ERASE = 1 and BYTE = 0, setting PPROG will initiate an erase sequence on the entire EEPROM memory. called BULK ERASE. 8.3.3 T

19、he CONFIG RegisterThe CONFIG register consists of eight EEPROM cells, organized as a register located in the I/O register block of the MCU. The CONFIG register can be erased or programmed just like any other EEPROM location, The structure of the CONFIG register of 68HC11F1 is as follows:*NOCOP=l dis

20、ables the COP (Computer Operating Properly) warchdog,*ROMON=1 enables the internal ROM.*EEON=l enables the internal EEPROM.Some members of the HCll family allow remapping of the EEPROM bloclc to the beginning of any 4K boundary in the memory map,To this purpose ,the most singnificant four bits of th

21、e CONFIG registers,callsEE3:EE2:EE1:EE are used to define the most significant four bits of the address of the EEPROM. For example ,if EE3:EE2:EE1:EE =0:1:0:1,then the starting address of the EEPROM is $5000.8.4 THE EEPROM Memory of the AVR Microcontrollers There are significant differences in the w

22、ay the EEPROM memory is implemented in AVR microcontrllers,compared to HC11. While in HC11,the EEPROM memory is directly visible in the memory map, and can be used as data memory or as program memory, for the AVRs the access to the EEPROM looks more like accessing data from a peripheral interface.8.

23、4.1 The Registers of the Interface with the EEPROM Memory Four registers control the access to the EEPROM.These are named EEARH , EEARL.EEARL and EECR.*EEARH - EEARL (EEPROM Address Regisrer Hi,gh/Low) form together a 16-bit register that implements the EEPROM address space.*EEDREEPROM Data Register

24、.This is used to access the EEPROM data,during the read and write operanons.*EECREEPROM Control Register contains the control bits for the write and read operations.EECR has the following structure. * EEMWE-EEPROM Master Write Enable. This bit provides a protection mechanism of the EEPROM data ,in c

25、ase of program runaway.The EEMWE is set by software,but is automatically cleared by hardware, after four cycles of themain system clock.In this interval of four cycles,it is possible to initiate a write operation to the EEPROM,by writing 1 to EEWE.Attempts to write to EEWE when EEMWE=0 haveno effect

26、.EEWE is cleared by hardware when the supply voltage. Therefore,it is recommended to poll EEWE, to determine the end of the write operation.*EERE-EEPROM Read Enable,This bit selects the access type to the EEPROM,EERE=1 indicates a read operation, while EERE=0 indicates a write operation.8.4.2 Softwa

27、re Routones to Read and Write EEPROM Reading a Byte from EEPROMThe following program sequence reads in R16 an EEPROM byte from the address indicated by register Z. It starts by testing EEWE to determine if the interface is ready.If EEWE=0 the contents of Z are transferred to EEARH-EEARL, then

28、 a control world is written to EECR having EERE=1(read operation).The EEPROM data is now readable in EEDR. EERead: SBIC EECR,EEWE ;確保 EEWE=0 RJMP EERead OUT EEARH,ZH ;write address in EEARH-EEARL OUT EEARL,ZL LDI R16,$01 ;EERE=1 - read operation OUT EECR,R16 IN R16,EEDR ;read data in R16 RET

29、Writing a Byte To EEPROM The subroutine described below writes the byte in R16 to the EEPROM address specified by Z.The following sequence of operation is performed:*Check EEWE to determine if the interface is ready.*Write Z to EEARH:EEARL.*Write R16 to EEDR.*Set EEWME.*Set EEWE to start the actual

30、write operation.Here is program that executes these operations;EEWrite: SBIC EECR,EEWE ;make sure EEWE=0 RJMP EEWrite OUT EEARH,ZH ;write address in EEARH-EEARL OUT EEARL,ZL OUT EEDR,R16 ;write data to EEDR CLI ;disable interrupts LDI R16,$O4 ;EEMWE=1 OUT EECR,R16 LDI R16,$02 ;EEWE=1 OUT EECR,R16 SE

31、I ;enable interrupts RET Not that before launching the actual write command, the program disables all interrupts.The reason for this is that an interrupt occurring between the execution of steps 4 and 5 would delay the moment when EEWE is set beyond the limit of four cycles after EEMWE is set. Writi

32、ng EEWE in step 5 would find EEWME cleared by hardware, and the whole write operation would fail.9.1 In this ChaperThis chaper contains the description of a simple development board based on the microcontroller 68HC11F1.and related software utilities,intented to allow the user to write and test soft

33、ware applications for this microcontroller.9.2 Description of the Hardware ModuleA development system for the study of a microcontroller comprises a hardware module and a set of software utilities (cross-assembler,compiler,etc).Along with the data sheets and application notes from the manufacturer,t

34、his allows the user to reach a clear understanding of the resources and capabilities of that specific microcontroller,and to write and test software applications for it. The module presented here is one of the simplest possible.It is built around the Motorola 68HC11F1 microcontroller, operating with

35、 an external EEPROM memory AT28C256, easily reprogrammable around 10000 times.Test programs can be written directly to AT28C256 using a standard commercial EPROM programmer. The 68HC11F1 microcontroller dose not have internal program memory it is designed to work with external ROM in expanded mode .

36、 For this purpose, the microcontroller can provide up to four chip select signals for external memory or other I/O devices. The way these signals activate,their polarity and relative priority are software controlled. The schematic of the hardware module is presented in Fig.9.1.There are very few ext

37、ernal components ,besides the microcontroller. The program memory is connected directly to the address and data buses, anf the chip select signal CSPROG is provided by the microcontroller, without the need of an external address decoder.The external clock circuit is implemented using the crystal Q1

38、(8 MHz typical),the capacitor C5 and C6 (15-22pF) and the resistor R1(1-10M). This type of oscillator circuit is typical of all HC11 family members.The RESET circuit comprises the transistor T1 along with resistors R2, R3, R4,capacitorC9 and connector JP1. At power-up, the capacitor C8 starts chargi

39、ng through R2, feeding current to the base of T1.This saturates the transistor for a time interval comparable to R28C9,generating an active LOW pulse on the RESET line of the microcontroller. A similar process occurs when the terminals of JP1 are short-circuited, providing a means for manual reset o

40、f the module.The IC2 circuit (MAX232) along with capacitors C1,C2,C3,and C4 implement the typical RS232 interface presented in Chep.3.The control signals MODA,MODB and the external interrupts IRQ and XIRQ are pulled up to Vcc using four 10K resistors.The test of the I/O lines of the microcontroller

41、are brought to three header-type connectors SV1,SV2.SV3.The module is powered from a DC or ac adapter, able to deliver 9-12V at 250mA. The input voltage is applied through the bridge rectifier B1 to the voltage regulator IC4(7805) that generates the +5V supply voltage.9.3 Assembling and Testing the

42、ModuleAll the projects. described in this section come with detailed schematics and printed circuit board drawings available on the accompanying CD.The PCB drawings arec reated with Eagle 4.11 from CadSoft. A freeware version of this software is available for free download from Cadsoft, so that the

43、user can view,edit,and print all the schematics and the PCB drawing of the projects described in this book. The major advantage of this CAD software is that it is very easy to learn, and the freeware version, despite some limitations, still allows the user to design prerty complex microcontroller ba

44、sed circuits. Most companies manufacturing custom printed circuit boards accept drawings created with Eagle 4.1 1, and the cost per square decimeter of printed circuit board is reasonable. However, in this particular case, the circuit is so simple that it can be easily realized on a prototyping boar

45、d using the wire wrap technique. It is recomended to use appropriate IC sockets for all ICs, except IC4. Refer to Fig. 9.2 for a possible component layout of the PCB. Once you have the module assembled. follow this test sequence:l. Apply power to the module. without having the ICs inserted in the so

46、ckets.2. Check the +5 V voltage on every socket.3. Check the RESET circuit by measuring the voltage in the collector of Tl, When a short-circuit is applied to the terminals of JPI. the voltage on this point drops near O V. while without short-circuit it stays near the V value.4. Insert the ICs into

47、the sockets and apply power to the module. With an oscilloscope check the E clock on pin 4 0f the microcontroller. If you don't have an oscilloscope, use a voltmeter to measure the RESET signal on the collector of Tl. If the oscillator fails to operate, the clock monitor circuit of the microcont

48、roller will force this line to logic zero.5.If everying is alright,install the cross-assembler,as described in the next paragraph and assemble a simple software example,like the presented in this chapter in exercise X9.1.6.Using a commercial EPROM programmer, program the AT28C256 memory with the bin

49、ary file created by the cross-assembler,and check the expected behavior of the module.9.4 Description of the Software Components The freeware cross-assembler offered by Motorola for the HC11 family. Called AS11.EXE,is extremely simple and has many weak points. Among them,the most important are:* It does not allow the INCLUDE directive, thus forcing the user to write all the source code in a single file. This can be extremely inconvenient.For example, the source code for the free monitor offer

溫馨提示

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

最新文檔

評論

0/150

提交評論