Laboratory Three Advanced Input and Output Devices

Laboratory Three
Advanced Input and Output Devices
Objectives:
1.
2.
3.
4.
To implement output signal timing sequences.
Generating parallel signals to drive external devices
To implement a 5x7 Matrix Display.
Application of advanced input/output devices (keypads and matrix displays).
Note: all programming software should be written in C. If and when assembly language is required, you
will be explicitly told to compose assembly language (it will likely be provided).
Hardware Build:
i.
ii.
iii.
iv.
v.
Maintain the LED bars, one DIP switch and keypad based on Lab 2.
You may want to use the LED bar as a status display. It can show a cycle count, a state count, or
even the status of the output pins.
MIC5891 interfacing and operation.
74HCT595 interfacing and operation.
ULN2803APG wiring
Three 5x7 matrix display wiring and operation.
Task Note: Tasks one through four are getting the 5x7 matrix display to work. Therefore, any
delay timing method you wish to use is adequate. Task five combines the keypad and the display
and can be performed with whatever timing that is appropriate. Task six requires that the code be
written so that other operations can take place besides the keypad and display, critical signal
timing delays for driving logic devices are allowed/required but all other delays should be the
result of flags returned from either rti interrupts or counter/timer interrupts.
Task One:
Developing the outputs to drive the MIC5891.
a) Write a program that drives parallel output pins to provide the clocking, data and output enable digital
waveforms for the MIC5891. The waveforms must follow the device data sheet, including the required
timing for set-up and hold, clock pulse widths, etc.
b) Verify that a pattern of alternating 0’s and 1’s is correctly shifted into and through the device. The
serial output can be used with a logic analyzer to observe correct operations. Alternately, “pull-down”
resistors can be connected between the outputs and ground to observe when the resister is driven
(high) or not driven (low).
Task Two:
Developing the outputs to drive two series connected 74HCT595.
a) Write a program that drives parallel output pins to provide the clocking, data and output enable digital
waveforms for the 74HCT595. The waveforms must follow the device data sheet, including the
required timing for set-up and hold, clock pulse widths, etc.
b) Verify that a pattern of alternating 0’s and 1’s is correctly shifted into and through the device. The
serial output can be used with a logic analyzer to observe correct operations. Alternately, “pull-up”
Page 1 of 8
resistors can be connected between the outputs and 5V power to observe when the resister is driven
(low) or not driven (high).
c) Verify that a “walking one” can be injected at the DS serial input and transit through all 16 output
locations as the clock pins are toggled.
Task Three:
Driving the 5x7 matrix displays..
a) Complete the hardware build of the components required for the 5x7 matrix display.
b) Write an initial test program that uses task 1 code to shift the pattern 0xFF into the MIC5891 and then
enable the output enable. Then use task 2 code to provide a walking one to the 74HCT595 so that
the walking one is shifted at approximately one step/clock per second with the output enabled.
Notes: you may want to “initialize” the 74HCT595 before loading and enabling the MIC5891. If the
74HCT595 output enable is used, you may need a pull-down resistor, otherwise, the input impedance
of the ULN2803APG is the only discharge path.
c) Modify the code from the previous example to shift a 0xAA pattern into the MIC5891.
d) Modify the code from the previous example to shift a 0x55 pattern into the MIC5891.
e) Modify the code so that the walking one is shifted fast enough that the display appears to be on
continuously..
Note 1: You can now display the same pattern on all the display columns.
Note 2: It may be useful to have one LED bar show the desired row data and the other LED bar
to show the walking one location in the first 74HCT595.
Task Four:
Driving characters and number to the 5x7 matrix displays..
a) Write code that drives the characters “ECE” to the 5x7 matrix display. This program will require you to
serial transfer row data for a column to the MIC5891, set the walking one to the desired column and
then enabling the OE of the MIC5891. Prior to shifting in the next row of data for the next column, the
OE will have to be disabled.
b) Select another character, number or symbol set and repeat part a.
c) Use software break-points to stop the program and observe that the row data for each
column, one at a time, is correct.
Task Five:
Keypad to display with dip switch reset.
a) Write code that displays the hexadecimal value of the key pressed on the keypad. The most recent
key should appear on the least significant display with the previous key on the next highest display
and the one before that on the highest display. This “collects” the keypad key presses in the same
way a calculator does.
b) Modify the code so that one of dip switches clears the display when toggled.
Note: clearing is the process of loading a space (ASCII 0x20) into all three display locations.
Page 2 of 8
Task Six:
Advanced Keypad to display with dip switch reset.
a) Write code that performs keypad sampling and display multiplexing based on either rti interrupts or
counter/timer interrupts setting flags and having “flagged” operations executed in the programs main
loop. By construction, this means that the HC12 is free to do other processing the majority of the
time.
Page 3 of 8
MIC5891YN Data Sheet Information
www.micrel.com/_PDF/mic5891.pdf
Functional Block Diagram
Suggested Connections (non-power or output):
Clock
Serial Data In
Strobe
Serial Data Out
Output Enable
Load Supply
to HC12 Parallel port
to HC12 Parallel port
tied high (always enabled)
no connect (probe to verify shifting)
to HC12 Parallel port
initially 5 V
Page 4 of 8
Page 5 of 8
NXP 74HCT595 Data Sheet Information
www.nxp.com/documents/data_sheet/74HC_HCT595.pdf
Functional Block Diagram
Suggested Connections (non-power or output):
DS
SHCP
MR
STCP
Q7S
OE (output enable)
to HC12 Parallel port
to HC12 Parallel port
optional connection to HC12 Parallel port
to HC12 Parallel port
to DS of 2nd device, 2nd device no connect
to HC12 Parallel port
Note: it is possible to tie SHCP and STCP to the same pin.
Page 6 of 8
See the data sheet for detailed timing requirements.
Page 7 of 8
ULN2803APG Data Sheet Information
http://www.semicon.toshiba.co.jp/info/docget.jsp?type=datasheet&lang=en&pid=ULN2803APG
Page 8 of 8