Lab 02 Pre Lab
Lab 02 Pre Lab
Pre Lab
Lab 02 - Parallel Port I/O (Part I)
Introduction
In computing, the parallel port is an interface used on computers for connecting peripheral
devices such as printers ( in the early days). In a parallel port, data is sent parallelly; multiple
bits of data at once. i.e.: parallel data communication.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
#define DATA_PORT 0x378 /* parallel port base address */
#define STATUS_PORT DATA_PORT+1
#define CONTROL_PORT DATA_PORT+2
void main(){
if (ioperm(DATA_PORT, 1, 1)){
fprintf(stderr, "Access denied to %x\n", DATA_PORT), exit(1);
}
if (ioperm(STATUS_PORT, 1, 1)){
fprintf(stderr, "Access denied to %x\n", STATUS_PORT), exit(1);
}
status = inb(STATUS_PORT);
data = status;
outb(data, DATA_PORT);
}
ioperm function set port input/output permissions. inb does the port input and outb does
the port output. Please refer to Linux man pages for more information about arguments and
return values.
Part 03: Display 0-9 numbers on a single 7 segment display using 74LS47
IC
3. Draw the circuit diagram that includes a 7-segment display, 74LS47 IC, and the
parallel port. Refer to the datasheet of the 74LS47 IC to find the least significant bit of
the output. (Use common anode)
4. Write the program to display characters from 0-9 in an infinite loop with a delay of 1
second between each character.
Part 04: Change the numbers displayed in the SSD with a push button
1. Draw the circuit diagram that includes a push button to take inputs, a 7-segment
display, and 74LS47 IC to show outputs and the parallel port. Make sure you use
proper resistors (pull-up/pull-down) when taking inputs through the push button.
Lab Submission
Create a report including the answers for the Pre Lab exercise. Include all the circuits (take
photos), calculations, answers, and code segments in the report in order of the exercise.
Name the report using your group members E numbers. Eg: E18XXX E18XXX.