1 / 15

CET 3510 Lecture 8 Dr. José M. Reyes Álamo

CET 3510 Lecture 8 Dr. José M. Reyes Álamo. Parallel Ports of PC Methods of interfacing Examples. Parallel Port of PC. The parallel port consist of 25 pins: 8 data input/outputs 4 control outputs 5 status inputs 8 pins are grounded. The registers found in standard parallel port are:

loman
Download Presentation

CET 3510 Lecture 8 Dr. José M. Reyes Álamo

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CET 3510 Lecture 8Dr. José M. Reyes Álamo Parallel Ports of PC Methods of interfacing Examples

  2. Parallel Port of PC The parallel port consist of 25 pins: • 8 data input/outputs • 4 control outputs • 5 status inputs • 8 pins are grounded

  3. The registers found in standard parallel port are: • Data register • Status register • Control register 25 pin female (DB25) connector

  4. Parallel Port Details

  5. Parallel Port Details (Cont.)

  6. Parallel port registers • Data registers are connected to data lines. • Control registers are connected to control lines. • Status register is connected to Status lines. • What you write to these registers, will appear in corresponding lines as voltages. You can measure it with a Multimeter. • Whatever you give to parallel port as voltages can be read from these registers • For example, if we write '1' to Data register, the line Data0 will be driven to +5v (actually 3.5 V). This way we can programmatically turn on and off any of the data lines and control lines.

  7. Where are these registers? • In an IBM PC, these registers are IO mapped and will have unique address. We have to find these addresses to work with parallel port. • For a typical PC , • the base address of LPT1 is 0x378 • the base address of LPT2 is 0x278. • The data register resides at this base address • The status register at base address + 1 • The control register is at base address + 2. • So once we have the base address, we can calculate the address of each registers in this manner. The table in the next slide shows the register addresses of LPT1 and LPT2.

  8. Where these registers are ? (cont.) • The parallel port consists of three bytes in the PC I/O address space, starting at address 0x378. • The first byte at 0x378 is for 8 bits of output • The second byte at 0x379 is for 5 bits of input, 3 bits unused • The third byte at 0x37A is for 4 bits of output, 4 bits of setup • 0x378 is the address of the parallel port data register

  9. Using the Parallel Port • Base port numbers: 0x378, 0x278 • The normal method • Call linux.ioperm() to get permission to access the ports • Use in() to read from the port (check x86 Instructions) • Use out() to write to the port (check x86 Instructions) • The command #include(“linux.hhf”) provides the library for the functions of linux.ioperm()

  10. Using the Parallel Port • The function ioperm (...) is Linux specific. • It allows an application program to access to the 80x86 I/O-addresses within the range 0x000 to 0x3ff. • Call ioperm() to get permission to access the ports • Use in() to read data from the port. • These instructions read a byte, word, and double word from an input port and place the input data into the accumulator register. • Must use DX register to hold the 16-bit port number • Example: in($379, AL) to read data from port $379 (line 10-line13) and place the information into the register AL

  11. Using the Parallel Port • out( ) provides a HLA language interface to the machine instruction that outputs the accumulator to the specified port (i.e., I/O port) using the I/O address space instead of the memory address space. • Must use DX register to hold the 16-bit port number Example: mov($FF, AL); mov($378, DX); out(AL, DX) // this will send binary data 1111_1111 stored in AL to data port $378 (line2 - line9)

  12. Permissions • Give your program permission to access the port. This is done by calling the ioperm() function • The syntax is ioperm(from, num, turn_on) , where: • from is the first port number to give access to • num the number of consecutive ports to give access to • turn_onis a boolean value. • Example: ioperm(0x300, 5, 1) would give access to ports 0x300 through 0x304 (a total of 5 ports). The last argument is a Boolean value specifying whether to give access to the program to the ports (true (1)) or to remove access (false (0)). You can call ioperm() multiple times to enable multiple non-consecutive ports. • ioperm() can only give access to ports 0x000 through 0x3ff; • The ioperm() call requires your program to have root privileges; thus you need to run it as the root user

  13. User number (value) will display the LEDs that are corresponding to the binary sum • LEDS are connected to pins D0 to D7 and to the ground pins, respectively • Light the LED or output data (value) by out(AL, DX) • Value of AL is associated with the pins of the parallel port • Example: To light D0 to D3you should call mov(15, AL); mov($378, DX); out(AL,DX); 1 + 2 + 4 + 8 = 15.

  14. How to calculate your own values to send to program • You have to think the value you give to the program as a binary number. • Every bit of the binary number control one output bit. The following describes the relation of the bits, parallel port output pins and the value of those bits. Pin 2 3 4 5 6 7 8 9 Bit D0 D1 D2 D3 D4 D5 D6 D7 Value 1 2 4 8 16 32 64 128 Note: The value above is the numeric value to send to printer port

  15. How does it look In HLA under Linux? program Interface; #include(“stdlib.hhf”); #include(“linux.hhf”); begin Interface; stdout.put ("You must be root to run this program“, nl); linux.ioperm($378,3,1): //open port //Get a data from keyboard by stdin.get(AL); //Similar get a port number from key board mov($AA, AL); mov($378,DX); out(AL,DX); //send 1010 1010 to port $378 linuxioperm($378,3,0); //close port End Interface;

More Related