Exercise9 - 0306-250 Assembly Language Programming Fall...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0306-250 Assembly Language Programming Fall 2009 Laboratory Exercise Nine: Timer Driver Stopwatch This exercise develops a timer driver for the Freescale HCS12 MCU Application Module. It uses the HCS12 enhanced capture timer (ECT) with channel seven output compare. The objective of this exercise is to implement interrupt-based timing measurements accurate to within 0.01 s (i.e., 10 ms = 1 cs). An interrupt service routine (ISR) and a driver program are written, and they are run on the HCS12 module. Prelab Work 1. Write the code to initialize the ECT to generate a channel seven output compare (OC7) interrupt every 0.01 s from a timer clock of 250 MHz. Also, write the code to “install” the ECT_OC7_ISR interrupt handler. 2. Write an ISR, named ECT_OC7_ISR, for the enhanced capture timer (ECT) module. On an ECT interrupt, if the variable RunStopWatch is not zero, ECT_ISR increments the variable Count; otherwise it leaves Count unchanged. Make sure to clear the interrupt condition in the ISR. Program Specification You need to write a program that works with the ISR and timer initialization from your prelab work along with the SCI0 ISR from Lab Exercise Eight to provide a user interface and functionality for a stopwatch that can time in hundredths of seconds. Below is the sequence of operations the program must perform. 1. Initialize the HCS12 SCI0 for interrupt-driven serial I/O using a format of eight data bits, no parity, and one stop bit—as in Lab Exercise Eight. (Note: The SCI0 ISR from Lab Exercise Eight is also used.) 2. Initialize the Boolean stopwatch run (byte) variable RunStopWatch to 0. 3. Initialize the stop watch clock count (word) variable Count to 0. 4. Using the code from prelab work, initialize the HCS12 ECT. 5. Using the properly documented PutString subroutine from Lab Exercise Four, output the character string below to the terminal screen followed by a carriage return character ($0D) and a line feed character ($0A) to advance the cursor to the beginning of the next line, and then output “>” as a prompt, as shown below. Press key for stopwatch command (c,d,h,p,t) > Page 1 of 3 0306-250 20091 Lab Exercise 9: Timer Driver Stopwatch Page 2 of 3 6. Using the properly documented GetChar subroutine from Lab Exercise Eight, accept a single-character command typed on the terminal keyboard, as specified below. (For the output specified below, use properly documented subroutines PutChar from Lab Exercise Eight, PutString from Lab Exercise Four, and/or PutNumW from Lab Exercise Seven, as appropriate for the type of output.) · C or c: Clear—echo the character typed, advance to a new line, print a prompt > character, and set the stop watch clock count variable Count to zero. >c > · D or d: Display-echo the character typed, print the current value of the stop watch clock count variable Count, print the time unit, advance to a new line, and print a prompt > character. >d: > · H or h: Help—echo the character typed, print a brief help message, move the cursor to the beginning of the next line, and print a new prompt > character. >h: > · 2009 cs C(lear),D(isplay),H(elp),P(ause),T(ime) P or p: Pause—echo the character typed, advance to a new line, print a prompt > character, and set the stop watch run variable RunStopWatch to 0. >p > · T or t: Time—echo the character typed, advance to a new line, print a prompt > character, and set the stop watch run variable RunStopWatch to 1. >t > · Any other character: Invalid—echo the character typed, print an error message/instruction that input was invalid, move the cursor to the beginning of the next line, and print a new prompt > character. >?: > unknown stopwatch command (c,d,h,p,t) 7. Repeat step 6. Lab Procedure 1. Create a new CodeWarrior directory (folder) and project on your X: drive for this exercise. 2. Write a properly commented and properly formatted HCS12 assembly language program to implement a timer driver and stopwatch, which functions according to the preceding specification. 3. Assemble the program in CodeWarrior compiler to create a listing file. 4. Link the program in CodeWarrior to create a linker map file. 0306-250 20091 Lab Exercise 9: Timer Driver Stopwatch Page 3 of 3 5. Test your program. Make sure to test this sequence of inputs/operations, which must be demonstrated to the instructor. a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. t. u. v. Input of D or d. Input of D or d. Input of T or t. Input of D or d. Input of D or d. Input of C or c. Input of D or d. Input of D or d. Input of P or p. Input of D or d. Input of D or d. Input of T or t. Input of D or d. Input of D or d. Input of P or p. Input of D or d. Input of D or d. Input of C or c. Input of D or d. Input of D or d. Input of H or h. Input of invalid command character. 6. Demonstrate step 5 for your lab instructor, who will sign your grading sheet. Then print the terminal screen output, your listing file, linker map file, and get your lab instructor to sign them. Report Write a report consisting of the following sections. · Abstract · Procedure · Results · Conclusion Your writing should follow the rules of professional technical writing and should meet the specifications in “Laboratory and Report Guidelines” on the course reference material web page. Staple your cover page, report, listing file, and grading sheet (in that order), and submit them at the beginning of the next lab session. Late reports are penalized 20% per day late, where “day late” is calculated by rounding submitted time to the nearest greater or equal integer number of days late (i.e., ceiling function). ...
View Full Document

This note was uploaded on 05/06/2010 for the course EECC 0306-250 taught by Professor Roymelton during the Fall '10 term at RIT.

Ask a homework question - tutors are online