DOC PREVIEW
NMT EE 308 - EE 308 – LAB 2

This preview shows page 1-2-3 out of 8 pages.

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

Unformatted text preview:

EE 308 Lab Spring 2008________________________________________________________________________EE 308 – LAB 2ASSEMBLY LANGUAGE PROGRAMMING AND 9S12 PORTSIn this sequence of three labs, you will learn how to write simple assembly language programs for the MC9S12 microcontroller, and how to use general purpose I/O (input/output) ports.Week 1Introduction and ObjectivesThis laboratory will give you more experience with the tools we will use this semester ― the MiniDRAGON+ evaluation board (EVB), the DBug12 monitor, and the as12 assembler. Be sure to read through the entire lab and do the prelab for each section before coming to lab1. Consider the program in Figure 1:Figure 1. Demo program for Part 1 of Lab 2.PreLab•Handassemble this program, i.e., determine the opcodes the MC9S12 will use to execute this program.•How many cycles will this take on the MC9S12? (Do not consider the swi instruction.)•How long in time will this take. (Note: the MC912 executes 24 million cycles per second.)•What will be the state of the N, Z, V and C bits after each instruction has been executed (ignore the swi instruction.)• What will be in address 0x2000 and 0x2001 after the program executed?a) Assemble the program using as12. Look at the lst and s19 files. You should be able to relate the opcodes from the prelab to the data in the s19 file.EE 308 Lab Spring 2008________________________________________________________________________b) Trace through the program. Verify that the Z, N, V and C bits are what you expect after each instruction.c) Look at the contents of address 0x2000. Does the value agree with your answer from the prelab?d) You could change this program to add rather than subtract by changing the sba instruction to an aba instruction. Modify the program, assemble it and load the new program into the MC9S12.a. Find the address for the sba instruction.b. In the MC9S12 Core Users Guide, find the op code for the aba instruction.c. Go to the address of the sba instruction, and change the op code to that of the aba instruction.d. Run the program again, and verify that the program now adds rather than subtracts.Consider the program in Figure 2, which is a program to divide a table of ten values by 2.Figure 2. Demo program for part 2 of lab 2a)Use the text editor to enter this program, assemble the program into an s19 file.b)How may cycles will it take to execute the program take on the MC9S12?EE 308 Lab Spring 2008________________________________________________________________________c)How long will it take to execute the program?d)Use the fill option to change the values in addresses 0x2000 through 0x2FFF to 0xff. Reload the s19 file.e)Set a breakpoint at repeat.f)Execute the program again. The program should stop the first time it reaches the repeat label, with 0x0a in acc b, and 0x2000 in x.g)Continue running the program. It should stop each time it gets to the repeat label – b should be decremented by one, x should be incremented by one, and there should be a new entry in table2.Consider the code of Figure 3. Do parts (a) and (b) below before coming to labFigure 3. Demo program for part 3 of lab 2.Question to answer before lab:•How many cycles will this program take on the MC9S12? (Again, ignore the swi instruction.)• How long will it take to execute this program?•Use a text editor to enter the code into a program – you will have to add org statements and other assemble directives to make the program work.a) Assemble the program and run it on the HC12. How long does it take to run?This time should match your answer to part (a)EE 308 Lab Spring 2008________________________________________________________________________WEEK 2Introduction and ObjectivesThe purpose of this laboratory is to write a few assembly language programs and test them on your MC9S12.PreLabMake sure you have the programs written and clearly thought out before you come to the lab. You should put all your code starting at memory location 0x2000. You are encouraged to bring the programs in on a disk.The LabAs in last week’s lab you will write some programs in assembly language and run the programs on the MC9S12. Write the program in Figure 1 and add necessary instructions to make it run.The MniDRAGON+ has a sevensegment LED display connected to the MC9S12 Port H.A sevensegment display looks like this:On the MiniDRAGON+, the a LED is connected to bit 0 of Port H, the b LED is connected to bit 1 of Port H, etc. (Bit 7 of Port H is connected to an infrared detector; it is not used to manipulate the seven segment LED display.) To display the number 3 on the LEDs, you need to turn on segments a, b, c, d and g. To do this, you need to write a 010011112, or 0x4f, to the Port H data register. (A 0xCF will also display a 3 on the LEDs, because the most significant bit can be either 0 or 1.) The following program will toggle the a LED of the seven segment display:EE 308 Lab Spring 2008________________________________________________________________________Figure 1. Demo program for part 2 of lab 2.b) Test your program on the MC9S12. Trace through the loop to see what is happening.Note: The program should cause one of the 7segment display to toggle.c) Modify the code to make all seven segments toggle in an alphabetical order.d) Write a program to swap the last element of an array with the first element, the next-to-last element with the second element, etc. The array should have 0x20 eight-bit numbers and should start at 0x2000.Check that your program works on the MC9S12. Use the following data for yourtest:e) Write a program which puts the exclusive OR of the eight-bit numbers form memory locations 0x8000 through 0x8FFF into memory location 0x2003. (This operation is often used to generate a check sum to verify data transmission. The sending computer generates and transmits the check sum along with the data. The receiving computer calculates the check sum for the received data and compares it with the check sum sent by the sending computer. If the two values do not match, then there was an error in the transmission (The last byte in a line of an S19 file is a check sum used for this purpose.)EE 308 Lab Spring 2008________________________________________________________________________WEEK 3Introduction and ObjectivesIn this week’s lab you will write an assemblylanguage program to display various patterns on the 7segment display. You will use the MC9S12’s Port H as an output port to display the patterns,


View Full Document

NMT EE 308 - EE 308 – LAB 2

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