Exercise8 - 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 Eight: Serial I/O Driver This exercise develops a serial I/O driver for the Freescale HCS12 MCU Application Module. The objective of this exercise is to implement interrupt-based serial communication with the HCS12 SCI using queues for serial data. An interrupt service routine (ISR) and a driver program are written to work with the queue code from exercise five, and they are run on the HCS12 module. Prelab Work First, following the specifications below and the notes you have taken in lecture, rewrite these subroutines from Lab Exercise Five to work with receive and transmit queues. You must write the subroutines so that no registers other than output parameter registers and CCR have changed values after return (RTS). · GetChar: Dequeues a character from the receive queue (RxQBuffer), and returns it in B. · PutChar: Enqueues the character from B to the transmit queue (TxQBuffer). Next, following the specifications below and the notes you have taken in lecture, write the ISR that handles SCI0 transmit and receive interrupts: SCI0_ISR. Finally, write the code to initialize SCI0 for interrupt-based I/O, the code to initialize the receive and transmit queue management record structures (RxQStruct and TxQStruct), and the code to “install” the SCI0 interrupt handler. Program Specification You need to write a program to test your serial I/O driver from prelab. Below is the sequence of operations the program must perform. Note that this functionality is identical to the program written for Lab Exercise Five. 1. Initialize the queue record structure (QStruct) for a queue buffer (QBuffer) of 25 characters, (i.e., bytes). 2. Initialize the receive queue record structure (RxQStruct) for a receive queue buffer (RxQBuffer) of 80 characters, (i.e., bytes). 3. Initialize the transmit queue record structure (TxQStruct) for a transmit queue buffer (TxQBuffer) of 80 characters, (i.e., bytes). Page 1 of 4 0306-250 20091 Lab Exercise Eight: Serial I/O Driver Page 2 of 4 4. Initialize the HCS12 SCI for interrupt-driven serial I/O using a format of eight data bits, no parity, and one stop bit at 9600 baud—same format and speed as previous lab exercises but with interrupts instead of polling. 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. Type up to 78 characters, and then press the Enter key. > 6. Using the properly documented GetChar subroutine from prelab work, accept characters typed on the terminal keyboard until the carriage return character is received. For each of up to the first 78 characters entered, (1) echo the character to the terminal screen, (2) increment it, and (3) call Enqueue to put it in the program queue (QBuffer). For any character beyond the first 78 and before the carriage return, accept the character but do not echo, do not increment, and do not call Enqueue. After each call to Enqueue, check to see if the operation was successful, and keep a running count of the number characters that failed to be enqueued. After the carriage return character is received, output a carriage return character and a line feed character to move the cursor to the beginning of the next line, and then output “<” as a marker, as shown below. Type up to 78 characters, and then press the Enter key. >Up to the first 78 characters typed by the user are here. < 7. Store the total number of characters that failed to enqueue (counted in specification 6) to a variable in RAM. 8. Until the program queue (QBuffer) is empty, call Dequeue and output the dequeued character to the terminal screen using the properly documented PutChar subroutine from prelab work. On the terminal screen, the dequeued characters should appear immediately after the “<” output marker character, as shown below. Type up to 78 characters, and then press the Enter key. >Up to the first 78 characters typed by the user are here. <Vq!up!uif!gjstu!89!dibsbd 9. After the last character in the program queue (QBuffer) is dequeued and printed on the terminal screen, move the cursor to the beginning of the next line. 10. Gently stop the program so that RAM variable with the enqueue fail count can be examined. (Alternatively, see Extra Credit Opportunity that follows Lab Procedure.) Notes: · The program is to use properly documented GetChar and PutChar subroutines that interface with SCI0_ISR via RxQBuffer and TxQBuffer, respectively. · This program is to use properly documented Enqueue and Dequeue subroutines from Lab Exercise Five. · This program is to use three circular FIFO queues: the program queue (QBuffer), the receive queue (RxQBuffer), and the transmit queue (TxQBuffer). RxQBuffer and TxQBuffer are reserved for interrupt-driven character I/O. Otherwise, this program 0306-250 20091 Lab Exercise Eight: Serial I/O Driver Page 3 of 4 uses the same code as written for Lab Exercise Five with modified GetChar and PutChar and new SCI0_ISR. 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 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. 5. Test your program. Make sure to test these input cases (i.e., after the prompt from specification 5), which must be demonstrated to the instructor. Input 1: No characters—enter key immediately after the prompt. Input 2: Between 1 and 25 characters. Input 3: Between 26 and 78 characters. Input 4: More than 78 characters. 6. Examine the HCS12 memory location containing the count of Enqueue failures after each input test case above, and record its value. 7. Demonstrate steps 5 and 6 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. Extra Credit Opportunity Instead of having the program stop as in program specification 10, print the number of enqueue failures and then repeat from program specification 5, as shown below. Print the text, “Number of failed enqueues: ” followed by the decimal value of the RAM variable holding the enqueue fail count. To print the value, create a PutNumB subroutine from your PutNumW subroutine of Lab Exercise Seven. PutNumB should print the unsigned byte value in B to the terminal using the ASCII characters for the digits of its decimal representation. Type up to 78 characters, and then press the Enter key. >Up to the first 78 characters typed by the user are here. <Vq!up!uif!gjstu!89!dibsbd Number of failed enqueues: 32 Type up to 78 characters, and then press the Enter key. > 0306-250 20091 Lab Exercise Eight: Serial I/O Driver Page 4 of 4 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, map file, terminal output, 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. ...
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