DOC PREVIEW
NMT EE 308 - EE 308 Introduction and Objectives

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 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 12 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 12 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 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Week 1WEEK 2WEEK 3EE 308 Spring 2006ASSEMBLY LANGUAGE PROGRAMMING AND 9S12 PORTS In 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 D-Bug12 monitor, and the as12 assembler. Be sure to read through the entire lab and do the pre-lab for each section before coming to lab1. Consider the program in Figure 1:prog: equ $1000 ; put program at address 0x1000data: equ $2000org progldab #29 ; IMM (immediate) address modeldaa #235sbastd result ; EXT (extended) address modeswi org dataresult: ds.w 1 ; Set aside one byte of memory for resultFigure 1. Demo program for Part 1 of Lab 2.Page 1EE 308 Spring 2006Pre-Lab•Hand-assemble this program, i.e., determine the op-codes 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 op-codes from the pre-lab to the data in the s19 file. (A document showing the format of the Motorola S19 files is available in the document S_RECORD.TXT on the EE308 datasheet page..)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 pre-lab?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.2. Consider the program in Figure 2, which is a program to divide a table of ten values by 2.Page 2EE 308 Spring 2006; MC9S12 demo program Bill Rison 1/15/03; This is a program to take a table of data, and create a new table which is the original; table divided by 2prog: equ $1000 ; put program at 0x1000data: equ $2000 ; put data at address 0x2000count: equ 10 ; number of entries in tableorg prog ; set program counter to 0x1000ldab #count ; ACC B holds number of entries leftldx #table1 ; Reg X points to entry to processrepeat: ldaa 0,x ; get table1 entry into ACC Aasra ; divide by 2staa count, x ; save in table 2inx ; Reg X points to next entry in table1decb ; decrement number left to processbne repeat ; if not done, process next table1 entryswi ; done - exitorg data; initialize table 1 (COUNT bytes long)table1: dc.b $19,$a7,$53,$e3,$7a,$42,$93,$c8,$27,$cftable2: ds.b count ; reserve count bytes for table2Figure 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? 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. Page 3EE 308 Spring 20063. Consider the code of Figure 3. Do parts (a) and (b) below before coming to labldy #100loop1: ldx #25000loop2: dexbne loop2 ; conditional branch to loop2deybne loop1 ; conditional branch to loop1swiFigure 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)Page 4EE 308 Spring 2006WEEK 2Introduction and ObjectivesThe purpose of this laboratory is to write a few assembly language programs and test them on your MC9S12.Pre-LabMake 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 seven-segment LED display connected to the MC9S12 Port H. A seven-segment display looks like this:Page 5abcdefgEE 308 Spring 2006On 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:PTH equ $260DDRH equ $262movb #$ff,DDRH ; make H an output portclr PTH ; clear port H data registerrepeat: bclr PTH,$1bset PTH,$1jmp repeatswiFigure 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 7-segment


View Full Document

NMT EE 308 - EE 308 Introduction and Objectives

Documents in this Course
Load more
Download EE 308 Introduction and Objectives
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 Introduction and Objectives 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 Introduction and Objectives 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?