
Lab 6
Parallel I/O: Lights and 7-segment Display
Before the Lab
The most commonly used method of exchanging information between a microprocessor system and the outside world is through parallel
I/O. The MC68HC11 micro controller has 5 parallel ports (A,
B, C, D,
E). Some of these ports have dual functions so they can be used as
I/O ports or as special function pins like data or address bus. In the single chip mode all the ports are available. In the expanded mode, ports
B and C are used for the data and address bus. In the
HC11-VDK board, port D is used for serial communication and the real-time clock. Port
A is reserved to be used with the internal timers in the MC68HC11
micro controller. This leaves us with only port E, which can be used either as an 8 analog input to the internal A/D or as a digital input port.
Another chip is used with the MC68HC11 micro controller, which is the MC68HC24 Port Replacement Unit (PRU). This chip allows us to restore ports
B and C that are used by the data and address bus. Port
C can be used as a programmable I/O port which means that we can define which bits to be inputs and which ones to be output. It also supports
I/O with handshaking.
For this lab, you are going to use port E as an input port and port
C as an output port. The address of port E is
$100A, so by loading data from this address, you can read the state of the pins of port
E. Port C will be used as an output
port. To program the direction of the port, you need to write to the data direction register of port
C that is located at
$1007. Writing a 1 to a bit will set it as output and writing a
0 will set it as input.
The I/O devices are located in the satellite board which has 8-bit dip switches, 8
LEDs, two 7-segment displays and an 8-bit D/A. The input port is connected to the dip
switches. The output port is connected to the LEDs, the 7-segment displays and the D/A. Jumper JPl on the board will either
connect the output port to the LEDs or to the Displays.
Seven-segment displays are now widely used in almost all microprocessor-based instruments. A single seven-segment
display can display the digits from 0 to 9 and the hex. digits A to F. Each display is composed of seven LEDs that
are arranged in a way to allow the display of different digits using different combinations
of LEDs. Since the display is composed of LEDs, which need high current to drive them, power consumption is very critical. Consider a panel with 4 displays and the number to be displayed is
8888. Each LED needs 20
mA. So we need a current of 20x7x4 = 560 mA. That's a lot of current compared to the current consumed by the microprocessor. Another problem is the number of components and output bits that are needed to connect the displays to the processor. We need at least 4x7 = 28 resistors and 28 output bits for the 4 displays. Is there a solution for these problems? Yes, there
is, it's called MULTIPLEXING!
Multiplexing can solve both problems at the same time. By activating only one display at a time, power
consumption will be reduced to the amount needed for only one display. Also, the number of components will be reduced by the same ratio since all the displays will share the same data bits and components. But what does multiplexing mean? It means that only one display will have current flowing through it at one time. This means that we need a switch to enable or disable current from flowing through each display. Remember that we cannot use any TTL gate to supply the current since it is much more than its normal output current that it can supply.
There are two types of seven-segment displays, common anode and common cathode. In common anode, all the anodes of the LEDs are connected together in a common point. By connecting this point to the supply we can activate the display. The data bits are connected to the cathodes of the LEDs. So, if
one of the bits is low; current will flow through the corresponding LED and turn it ON. For the common cathode display, the common cathode is connected to the GND and the bits are connected to the anodes of the LEDs. Remember that we cannot use the output bits directly from the processor to the display since they cannot sink or source enough current.
So, we need to use a driver for this job.
How can the 4 displays display at the same time? They cannot! But, if the multiplexing frequency is high enough, our eyes will not be able to detect the switching in the displays and they will seem to be active at the same time.
Normally, a frequency above 50 Hz will be enough to create this illusion. But since the displays active only for one forth of the time, the intensity will be less than that of non-multiplexed display. Our eyes do the averaging job.
For
this lab, you are required to write programs that:
-
Copy the
switch settings to the LED's. This should be a continuous process, so that
when you change a switch status, the result is immediately apparent in the
LEDs. You can terminate the loop simply by pressing
RESET.
A nicer solution would be to detect a particular switch setting (e.g., all
0's
or all 1's)
and escape to
SWI
via a conditional branch.
-
Rotate a
single lit LED from left to right. Each LED should be lit for a reasonable
length of times (200 msec). When the light reaches the boundary of the 8
LEDs, flash all of them then continue.
-
Extend the previous program so that the
direction of rotation depends on one of the settings of the dipswitches.
-
Rotate a
pattern obtained from dipswitches, from right to left.
-
Display a two digit number stored at location
$C300 on the two displays. Remember that each digit needs only one nibble to store it. Your program will use the least significant seven output bits from port
C for the display data and the MSB to multiplex the displays. You should have a delay loop for multiplexing the display.
In the Lab
Test the I/O ports using the MM and
MD commands in the BUFFALO
monitor. Assemble, download and run your programs.
Try different frequencies for multiplexing and note the minimum frequency that will give a stable display.
After the Lab
-
Generate correct and annotated listings of your programs.
Provide details about how you connected the satellite board.
-
Can we use a NPN transistor instead of the PNP transistor for the seven-segment display? Why?
-
Estimate the power saving using this method compared to the non-multiplexed method.
-
Is the minimum multiplexing frequency you have noted realistic? Can you explain it?
| EE-218 Homepage |
Syllabus
| Schedule | Lab News | Faculty |
Contact
Information | Lab Info | Project
|
Department of Electrical Engineering and Computer Science
Box 1824 Station B
Nashville, TN 37235
Phone: 322-2771
Fax: 343-6702
|
Search |
Site Index
| People Finder
| Phone
Directory | VUnet |
VUmail |
VU Library | Help
|
Last Updated:
Saturday, March 05, 2005
Juan J. Rodriguez-Moscoso
Copyright © 2003
Vanderbilt University
|