Parallel port and programming

zhaozj2021-02-16  50

The parallel interface of the parallel port is developed from a simple printer interface. Early parallel ports are unidirection ports, which simply transmits data from the computer to the printer. With the emergence of two-way parallel, the use of parallel port is increasingly wide. Compared to the serial port it has the characteristics of fast transmission, high reliability, simple programming. It is gradually replacing the serial port in close communication.

Since the two-way parallel port is a unified specification that the manufacturer is designed alone. Gradually, the following parallel port mode: 1, the original parallel port SPP single-way 8-bit two-way 4-bit 2, simple two-way PS / 2 two-way 8-bit 3, enhanced parallel EPP high-speed two-way 4, extended parallel ECP high-speed two-way reliable 5, multi-mode Port ECP EPP can operate in a variety of modes

25 pin joint pipe foot distribution map

2-9 Data D0-D7 Bidirection 1 Trying / STB 14 Automatic Wrap / AFD Output 16 Initialization Init 17 Select / SiN

10 Answer ACK 11 Busy / Busy 12 Page Dight PE Input 13 Online SLCT 15 Error Error

18-25 Grounding GND returns

Port Address: 3BCH-3BEH 378H-37AH 278H 378H-37AH 278H-27AH where the first address is the base address, that is, the data register, the second is state, the third is the command register. The EPP register is a total of 5 registers at the base number 3 to 7. ECP is a register port bit allocation between the base address 400h to 402h: Status: D7 D6 D5 D4 D3 D1 D0 - -? Irq Sin init AFD STB

Command BUSY ACK PE SLCT Error - - -

Note: Some early parallel ports and all parallel ports now "?" 1 can enter data

Access port: Mainly there are direct I / O and indirect I / O. An indirect I / O includes BIOS, API, VXD, controls, and the like. Direct I / O: unsigned char InPort (unsigned short Addr) {unsigned char Data asm {mov dx, Addr in dx, al mov Data, al} return Data;} void OutPort (unsigned short Addr, unsigned char Data) {asm { The indirect I / O will be omitted here. Communication handshake: Generally, SIN, SLCT is used to contact. Output data from parallel: PC Detection Busy is busy, busy waiting. Send data, set STB, detect whether the ACK responds, is the STB otherwise waiting. The peripheral detection STB is stronger, and it is set to the busy. Otherwise, wait. Read data, processes the ACK to issue.

Enter data from parallel: Set "?" 1 set to input data. Does the peripheral test STB is busy, and wait. Send data, set ACK, detect if AFD responds, is that the ACK does otherwise wait. The PC detects whether the ACK is stronger, and it is set to wait for the STB. Read the data, the process is processed, AFD is powered.

The following is a class of computer receiving data: // ------------------------------------- ------------------------------------ // Start Paalle.h

#ifndef parallelh # define parallelh // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------- Class TParacomm {Private: Short DataAddr; Short StatusAddr; Short CommandDr; Unsigned__fastcall inPort (short Addr); void __fastcall OutPort (unsigned char Data, short Addr); public: __fastcall TParaComm (int PortAddr); void __fastcall InitComm (void); bool __fastcall GetConect (bool Wait); bool __fastcall ReadPort (unsigned char * Data, INT TIME);}; extern tpaComm * Para; # endif // end paralle.h

// Start paralle.cpp # include "paralle.h" TParacomm * Para; unsigned __fastcall tParacommmm :: inport (short addr) {unsigned char TEMP;

转载请注明原文地址:https://www.9cbs.com/read-28330.html

New Post(0)