EE26 Digital Logic Systems



EE14 Microprocessor Architecture and Applications

Fall Semester 2011

Notes 8 (10/13/2011)

Project #2 ASCII Display

Implementation due on Friday, October 21 for Friday section and Monday, October 28 for Monday section. The report due a week after.

SUMMARY

The goal of this lab is to practise HC12 Assembly Subroutine Programming with a simple program. This lab helps you understand how directives work, how subroutines are called, and get more familiar with the hardware.

INTRODUCTION

The M68HC12 evaluation board is factory-configured to execute D-Bug12, the Flash EEPROM-resident monitor program, without further configuration by the user. It is ready for use with an RS-232C terminal for writing and debugging user code. You can find the complete information about the board on our course site on Trunk System under “M68EVB912B32 Evaluation Board”. You can also find the debugger’s tutorial “D-Bug12 Reference Guide” there. The software we are going to use is MGTEKMiniIDE. It is installed on the PC's in Room 225. These PC's are on the network. All of your work should be saved in a removeable drive or in your NT account at the end of the lab. All work on the hard disk will be deleted at the end of the day. Saving your work in a removable drive will allow you to move your work between computers and avoid logistic problems with directories and file names. YOU ARE RESPONSIBLE FOR MAKING SURE THAT YOUR WORK IS SAVED!!

ASSIGNMENT

You are going to design and implement a program which can take a list of characters and print their hexadecimal code on the terminal. Put your program code in one SECTION, and the message you are going to print in the other SECTION. The pseudo code is as follows:

Begin program;

SECTION CODE

count = 0;

While(msg[count] != ‘00’)

{

count++;

Convert msg[count] to hexadecimal code;

Print the hexadecimal code on terminal;

}

Calculate execution time without printf;

Print execution time on terminal;

SECTION DATA

Store msg (end with carriage return and line feed) in memory;

First, you have to create a subroutine which converts a character to two ASCII hex bytes. For example, if the character you entered was ‘m’, the ASCII binary code of ‘m’ is %0110 1101. The upper nibble, %0110, is to be converted to $36 (the ASCII code for character “6”) and the lower nibble, %1101, is to be converted to $44 (the ASCII code for character “D”). The subroutine gets the binary value in Register B and returns two ASCII hex digits in Register D. For example, if B = %0110 1101, then Register D will return $3644. Below are some hints to help you create this subroutine.

1. Your subroutine will take the binary contents of Register B and convert each nibble in the byte to the equivalent ASCII code. To do this, you should follow:

Convert a nibble in the range of $0 to $F to the ASCII equivalent

IF the number is higher than 9

THEN subtract 9 and OR with $40

ELSE OR with $30

2. If you have a byte to convert to ASCII, you have to convert each nibble separately. You can do most significant nibble first and then the least significant one. To do this, you have to isolate each nibble.

An algorithm to do this is:

Isolate the most significant nibble from a byte

Logical shift right four bits

Convert to ASCII hex

Isolate the least significant nibble from a byte

AND the byte with $0F

Convert to ASCII hex

The HCS12 uses the E clock as a timing reference. The frequency of the E clock is half of that of the crystal oscillator (16 MHz). To calculate the execution time, you have to determine how many execution cycles are there in your loop. (Note: We are not counting in “printf”, we just want to calculate the execution time of your “character to ASCII” converter.) After you get the number of cycles, you can use the following equation to calculate the execution time.

[pic]E_Clock_Period [pic] # of cycles in each loop [pic] count

Lab Report

Write a report individually, follow the “Lab Report Guidelines” on our course site on Trunk System. Include the following in your report too.

• Try printing 3 messages with different lengths, record the execution times in your lab report.

• Check the listing file, understand how the directive “SECTION” changes the location counter.

• Turn off the power of the board, then turn it back on again. Check what’s in the memory address where you stored your message. Explain what happened to your program. Explain why you can always run D-Bug12 but not your own program when you turn the power on.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download