EE 308 -- LAB 03
Parallel Ports and Subroutines
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.
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.
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.
|PC 7||PC 5||Port B Function|