DOC PREVIEW
NMT EE 308 - EE 308 – LAB 11

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 Lab 10 Spring 2003EE 308 – LAB 11Port Expansion for the HCS12It is sometimes necessary to add additional memory and/or hardware to a microprocessor ormicrocontroller. Interfaces such as the SPI allow you to add some hardware, it is often necessaryto interface directly to the address/data bus. For a microprocessor, which does not have built-ininterfaces, the address/data bus is the only way to add additional memory or hardware. In this labyou will will add an external output port to your HC12.Figure 1 shows a block diagram for adding an external output port to the HCS19. We willimplement the port in an Altera 7064 PLD. Note that you will have to connect the 16-bit multiplexedaddress/data bus and three control lines from your HCS12 to you Altera chip. You will also haveto connect the eight bits of your output port to your LEDs to verify that the port is working.R/W = 0LATCHHC12EADDR(16)R/WLSTRBORLSTRB = 0CS_WPort A A/D 15−8Port B A/D 7−0E = 1LEDsADDR = 0x4054ADDR = 0x40558FFFigure 1. Block diagram of HCS12 output p ort at address 0x4055.1. Write an Altera program to implement the output port.2. Using the pinout diagram from the .rpt file, wire the Altera chip to your HCS12. Note thatthere will be a lot of wires to run, so it is essential that you are neat in your wiring.3. Check the functioning of your port using DBug12. When you start your HCS12 using DBug12,the HCS12 is in single chip mode. In this mode you c an manipulate AD15-0, E, R/W and LSTRBas general purpose I/O lines. You can use the MM command of DBug-12 to write data to theoutput port by changing AD15-0 (PORTA and PORTB), E, R/W and LSTRB in the samesequence that the HCS12 would if it were in expanded wide mode. Look at Chapter 12 ofthe HCS12 Core Users Guide for more information.(a) Use the DDRE register to make E, R/W and LSTRB output pins. (Note: E is bit 4 ofPORTE, R/W is bit 3 of PORTE, and LSTRB is bit 2 of PORTE.)(b) Bring E low by writing to PORTE.(c) Put 0x4055 on PORTA and PORTB.(d) Bring R/W and LSTRB low.1EE 308 Lab 10 Spring 2003(e) Bring E high.(f) Put the data you want to write to the port on PORTB.(g) Bring E low.When you bring E low in the final step, the data should appear on the LEDs. If this happens,your Altera code and your wiring is correct.4. Now you will switch the HCS12 into expanded wide mode, so the HCS12 can write directly tothe expanded output port using its address/data bus. Unfortunately, DBug-12 does not workwhen the chip is put into expanded wide mode. To verify that the expanded port works, youwill have to put your program into EEPROM, along with the instructions needed to switchthe HCS12 into expanded wide mode. Then by having the HCS12 execute EEPROM codeafter reset, you will be able to see that the expanded port works properly. Also, our HCS12has no region of free memory in which to map our new port. We can use the MISC registerto turn off the Flash EEPROM from 0x4000 to 0x7fff, which will give us a region in which toput our port. The following program will do all this:PEAR: equ $000aMODE: equ $000bEBICTL: equ $000eINITRM: equ $0010MISC: equ $0013SYNR: equ $0034REFDV: equ $0035CRGFLG: equ $0037CLKSEL: equ $0039COPCTL: equ $003cARMCOP: equ $003fCODE: section .textorg $400ldaa #$55 ; Reset COPstaa ARMCOPcomastaa ARMCOPclr COPCTL ; Turn off COPldab #$11 ; Map RAM into proper locationnopstab INITRMldab #$00 ; Set clock reference divider to 0stab REFDVldab #$03 ; Set PLL to multiply oscillator clock by 4stab SYNRnop ; waitnopnopnop2EE 308 Lab 10 Spring 2003l1: brclr CRGFLG,#$08,l1 ; Wait for PLL to lockbset CLKSEL,#$80 ; Switch to PLL clockldab #$e4 ; Expanded wide mode, internal visibility onstab MODEldab #$0c ; Turn on R/W, LSTRBstab PEARldab #$01 ; Use E-clock to control external busstab EBICTLldab #$03 ; No E-clock strech, disable ROM from 4000-7fffstab MISCAdd to the above program code which will increment the external port, with a delay betweenincrementing. Implement the delay using a software loop as you did in Lab 4.Note that you cannot increment your port through a simple command such asinc $4055because you would have to be able to read from your port as well as write to your port forthis to work. Instead, keep track of the value to write in a memory location, increment thisvariable, and write it to address 0x4055.5. A HCS12 with a functioning expansion port will be available at one of the logic analyzersduring lab this week. Writing to address 0x4055 will write data to the port. Reading fromaddress 0x4054 will read data from the port. The HCS12 is running the following loop:loop: ldaa $4054incastaa $4055bra loopThe label loop is at address 0x0480.(a) Hand-assemble this program to determine the op codes and op code addresses.(b) Use the logic analyzer to grab data from the HCS12 address/data bus. Identify thememory cycle which reads data from address 0x4054, and the memory cycle which writesdata to address 0x4055. Note that the logic analyzer has only 16 data lines. The HCS12address/data bus uses 19 lines — AD15-0 and the three control line E, R/W, and LSTRB.The HCS12 will either be fetching instructions from EEPROM (address 0x0400-0xfff),or accessing the external port (0x4054 or 0x4055). Thus, adress bits D15, D13 and D12will always be zero.Figure A-9 of the MC9S12DP256B Device Users Guide shows the external bus timing.As best you can, measure the following times. The numbers in parentheses are thelabeled numbers on Figure A-9 and Table A-20. Compare the numbers to the valueslisted in Table A-20.i. Cycle time (2)3EE 308 Lab 10 Spring 2003ii. Pulse width, E low (3)iii. Pulse width, E high (4)iv. Address dealy time (5)v. Muxed address hold time (7)vi. Write data hold time (13)vii. Read/write delay time (24)viii. Read/write hold time (26)ix. Low strobe delay time (27)x. Low strobe hold time (29)Pre-Lab1. Write a preliminary Altera program to implement the expanded ports.2. Hand assemble the instructions of Part


View Full Document

NMT EE 308 - EE 308 – LAB 11

Documents in this Course
Load more
Download EE 308 – LAB 11
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view EE 308 – LAB 11 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view EE 308 – LAB 11 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?