EE 308 -- LAB 04
Parallel Ports and Subroutines
Introduction

Ports B and C are the easiest HC11 parallel ports to understand and use. For this week's lab, you will create programs to write to Port B, and read from Port C. You will use the Port C input to control the Port B output. You will test your programs by connecting Port B to 8 LEDs, and vary the Port B output by changing Port C inputs between to 5 volts and ground.

Pre-Lab

Find the P4 MCU I/O Port Connector in the Universal Evaluation Board User's Manual, and locate the Port B and C pins. Write programs to implement (i) a binary up counter, (ii) a binary down counter, (iii) a flasher, and (iv) a turn signal. Samples from the sequences that you should generate are shown in Fig. 1. You will use eight LEDs to see the Port B output. Your eyes act as a low pass filter on flash rate: include an appropriate delay between LED on and LED off so that you can easily and comfortably see them flash -- use a subroutine to implement the delay. Use Port C bits 1 and 0 to control which of the Port B functions are performed as shown in Fig. 2.

Write all programs before coming to lab. Be mindful of the delay requirement before changing the display or reading the Port C pins to determine if you should switch to a new function. When you switch between functions, the new function should start up where it ended when it was last activated.

The Lab

  1. Wire up Port B to 8 LEDs, and Port C bits 1 and 0 to a connection that can be moved between 5 volts and ground. Use a switch on the Port C connections if you have it, otherwise just move the wires. Show the lab instructor that your program works as specified in Figures 1 and 2.

    Uncle Dad Advice

    Start with one function only, say, the one to increment Port B. Begin by testing it with no delay subroutine on the simulator. When it works there, put it onto your EVBU. Use a logic probe on the P4 pins to see if they are pulsing. Then wire Port B to 8 LEDs, and test the increment Port B program with the delay subroutine. Once you have this working, wire up one of the Port C bits, and get it to switch between two functions. Again, test your new function on the simulator first with no delay subroutine. After you get this second function working, then wire up both bits 1 and 0 on Port C and get your complete program working.

      

    1. A binary up counter:

    2. A binary down counter:

    3. A flasher:

    4. A Ford Thunderbird style turn signal that alternates between right and left:


    Figure 1: Samples of the functions to be performed using Port B as an output. ``'' is LED on and ``'' is LED off.

      

    PC 1 PC 0 Port B Function
    0 0 Up Counter
    0 1 Down Counter
    1 0 Flasher
    1 1 Turn Signal

    Figure 2: Port C inputs to control the Port B functions.

  2. Set a breakpoint at the first line of your delay subroutine. When the breakpoint is reached, check the value of the stack pointer, and the data on the stack. Make sure you understand what these mean.


Bill Rison, <rison@ee.nmt.edu >
Thr Feb 6 1997

© 1997, New Mexico Tech