DOC PREVIEW
NMT EE 308 - EE 308 – LAB 4

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 4 Spring 2003EE 308 – LAB 4Using the HCS12 Parallel PortsIntroductionBring your digital breadboard to this week’s lab! You will need to use the LEDs onit.In this week’s lab you will write an assembly-language program to display various patterns on theLEDs of your breadboard. You will use the HCS12’s Port A as an output port to display the LEDpatterns, and Port B as an input port to decide which pattern to display.Ports A and B are the easiest HCS12 parallel ports to understand and use. For this week’s lab,you will create programs to write to Port A, and read from Port B. You will use information fromswitches connected to Port B to control the pattern you output on Port A. You will test yourprograms by connecting Port A to 8 LEDs, and vary the Port A output by changing the switchsettings connected to Port B.Pre-LabWrite a program to set up Port A as an 8-bit output port, and to implement (i) a binary down up,(ii) a flasher, (iii) a psuedo-random code generator, and (iv) a turn signal on Port A. Samples fromthe sequences that you should generate are shown in Fig. 1. You will use eight LEDs to see thePort A output. Include an appropriate delay (about 200 ms) betwe en changing the LED patternso that you can easily and comfortably see them flash. Use a subroutine to implement the delay.Also, set up Port B as an 8- bit input port, and use Port B bits 4 and 1 to control which of thePort A functions are performed as s hown in Fig. 2. When you switch between functions, the newfunction should start up where it ended when it was last activated, so set aside variables to savethe states of the various patterns.Write the program before coming to lab. Be sure to write the program using structured, easy-to-read code. Be mindful of the delay requirement before changing the display or reading the Port Bpins to determine if you should switch to a new function.The Lab1. Run your program on the ZAP simulator. (Note that you will want to reduce the delayconsiderably before running on the simulator). You can simulate different input values onPort B by changing the value in Address $0001. If you have difficulty getting your programto work, start by trying to implement one function only — say, the down counter. Once thisworks, start working on your next functions.2. Set a breakpoint at the first line of your delay subroutine. When the breakpoint is reached,check the value of the s tack pointer, and the data on the stack. Make sure you understandwhat these mean.1EE 308 Lab 4 Spring 20031. A binary down counter:· · · · · · · ·• • • • • • • •• • • • • • • ·• • • • • • · •Continue counting down.2. A flasher:· • · • · • · •• · • · • · • ·Repeat the above sequence.3. Generate a pseudo-random code in the following manner: treat ACCA as an eight-bit shiftregister which shifts to the right. The number to input into the left-hand side of the shiftregister is the XOR of Bit 0 and Bit 4 of ACCA. (You can use the instruction RORA to dothis.)· · · · · · · •• · · · · · · ·· • · · · · · ·· · • · · · · ·· · · • · · · ·• · · · • · · ·· • · · · • · ·· · • · · · • ·· · · • · · · •Repeat the above sequence. This produces a sequence which repeats after twelve cycles. Bytaking the XOR of bits 0, 1, 6 and 7 you can generate a sequence which repeats every 255cycles, and appears to be random. (For your program looks at bits 0 and 4 rather than usinga table of twelve values.)4. A Ford Thunderbird style turn signal that alternates b e tween right and left:· · · · · · · ·· · · • · · · ·· · • • · · · ·· • • • · · · ·• • • • · · · ·· · · · · · · ·· · · · • · · ·· · · · • • · ·· · · · • • • ·· · · · • • • •Repeat the above sequence.Figure 1: Samples of the functions to be performed using Port A as an output. “•” is LED on and“·” is LED off.2EE 308 Lab 4 Spring 2003PB4 PB1 Port A Function0 0 Down counter0 1 Flasher1 0 Pseudorandom Code1 1 Turn SignalFigure 2: Port B inputs to control the Port A functions.3. After your program works on ZAP, load it into your HCS12. Wire up Port A to 8 LEDs, andPort B bits 4 and 1 to a connection that can be switched between 5 volts and ground. Usethe switches on your breadboard to connect to the Port B pins.Begin by wiring up the Port B pins to switches, and make sure you can read the state ofthe switches. You can do this using D-Bug 12 to display the contents of Address $0001 forseveral values of the switch settings. After you are sure you can read the state of the switcheson Port B, try running your program on the HCS12.When you get your program to work, have your lab instructor or TA verify the programoperation.4. Set a breakpoint at the first line of your delay subroutine. When the breakpoint is reached,check the value of the stack pointer, and the data on the stack. These should match whatyou found in Part 2 of the lab.5. The HCS12DP256 has EEPROM (Electrically Erasable Programmable Read Only Memory)between 0x0400 and 0x0FFF. If you put your program into EEPROM the program will remainthere when you turn off power. To put your program into EEPROM, all you need to do ischange the starting address of your program to 0x0400. Note that you will want to store thearray which has the turn signal patterns in EEPROM (so the array will not disappear whenyou turn off power). To do this include any tables of constant patterns in the CODE sectionof your program. You will want variables which will change as the program is executed to beplaced in RAM, say at location 0x2000, as usual.When D-Bug12 starts running, it checks the state of pins AD0 and AD1. If these are both low,D-Bug12 runs normally. If, however, AD0 is high and AD1 is low, D-Bug12 will immediatelyjump to your program in EEPROM. Thus, you can run a program without having to have theHCS12 connected to a serial port to receive a D-Bug12 command. In order for the HCS12 torun properly, however, your program must do some hardware setup which is normally doneby D-Bug12. To set up the hardware properly, your program needs to execute the followinginstructions. The reasons for doing this will be discussed later in the semester.ldaa #$55 ; Reset COPstaa $003fcomastaa $003fclr $003c ; Turn off COPldab #$11 ; Map RAM into proper locationnopstab $00103EE 308 Lab 4 Spring


View Full Document

NMT EE 308 - EE 308 – LAB 4

Documents in this Course
Load more
Download EE 308 – LAB 4
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 4 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 4 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?