EE 308 -- LAB 03
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 Port C bits 5 and 7 to control which of the Port B functions are performed as shown in Fig. 2.

The programs are similar to the homework. Write all programs before coming to lab. Put each of the Port B functions into subroutines, and call the appropriate routine according to the input at Port C pins 5 and 7. 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

Wire up Port B to 8 LEDs, and Port C bits 5 and 7 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 5 and 7 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 7 PC 5 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. The Port C input pins should be sampled at no less than 2 Hz.


Bill Rison, <rison@ee.nmt.edu >
Fri Jan 12 1996

© 1996, New Mexico Tech