EE 308 - LAB 6

Preliminary versiom from 2001


More Assembly Language Programming

Prelab

For the prelab, write the program discussed below.

The Lab

The HC12 has several ports (A, B, AD, T, S, P and DLC) which can be used for various functions. For example, Port S is used for serial communications - you talk to the PC terminal through Port S. Port T is used for accessing the HC12 timer. We will discuss this more in class over the next few weeks. If a port is not used for its specific function, it can be used for general-purpose I/O - e.g., if you are not using timer functions, you can use Port T in a manner similar to the way you use Ports A and B. Port AD can only be used for input; all the other ports can be used for either input or output, by writing to the Data Direction Register for that port. In this week's lab you will need to use more I/O pins than are available on Ports A and B alone. (Note that you should not use bits 0 and 1 of Port AD, or bits 0 and 1 of Port S, since these are dedicated to other functions on your evaluation board.)

In this lab you are to write a program which will use the DIP switches to enter two numbers into the HC12, and use the LEDs to display the results of some operations using these numbers.

Connect eight bits of one of the HC12's Ports to the eight DIP switches on your breadboard. Connect eight bits of another of the Ports to the eight LEDs on your breadboard. Connect one pin of a third Port to one of the debounced switches on your breadboard. Write an assembly language program to do the following:

  1. Set up the pins connected to the DIP switches as input, the pins connected to the LEDs as output, and the pin connected to the debounced switch as input.
  2. When you press the debounced switch the HC12 should read the state of the DIP switches, save this number in memory, and wait until the debounced switch is released.
  3. When you press the debounced switch a second time, the HC12 should read the state of the DIP switches, save this number in memory, and wait until the debounced switch is released.
  4. After the debounced switch has been released the second time, you should change bits 0, 1 and 2 on the DIP switches. Based upon these three bits, you should display the following on the LEDs:

    Bits 2,1,0 Function
    0 0 0 First number entered
    0 0 1 Second number entered
    0 1 0 Bitwise AND of the two numbers
    0 1 1 Bitwise OR of the two numbers
    1 0 0 Sum of the two numbers
    1 0 1 N, Z, V and C bits from adding the two numbers
    1 1 0 First number minus second number
    1 1 1 N, Z, V and C bits from subtracting the two numbers

    Note that the HC12 should continue to monitor these bits, so you can look at any or all of the results.

  5. If the debounced switch is pressed again, another number is being entered, so start over with (2).



Bill Rison
2001-02-21