B&B Electronics PPIO manual Controlling the Ppio Using Pascal, Begin

Page 14

CONTROLLING THE PPIO USING PASCAL

The PPIO disk includes two source code files as an example of using the PPIO with the Pascal programming language. PPIO.PAS is the main routine of the example program. PPIOUNIT.PAS contains the routines for communicating with the PPIO. In the rest of this section, we assume that you know the Pascal programming language. Consult your reference manuals if you need help with the language.

The Pascal Unit, PPIOUNIT.PAS handles communication with the parallel port. It defines five variables. They are defined as:

Input_Byte

: BYTE;

{ Byte that’s read from PPIO }

Output_Byte

: BYTE;

{ Byte that’s written to PPIO }

Base_Address

: WORD;

{ Base address of Parallel Port }

Status_Address

: WORD;

{ Status Register Address }

Control_Address

: WORD;

{ Control Register Address }

No function outside the Unit can directly access these variables. Functions outside the Unit call functions within the Unit to modify and return the value of these variables.

The procedure Set_Start, sets the variable Base_Address, Status_Address, Control_Address and Output_Byte. It also sets up the initial state of the parallel port. The function is defined as:

PROCEDURE Set_Start(Address:WORD; Init:BYTE);

BEGIN

Base_Address

:= Address;

{Parallel Port Base Address}

Status_Address

:= Base_address+1;

{Parallel Port Status Address}

Control_Address

:= Base_Address+2;

{Parallel Port Control Address}

PORT[Base_Address]:= Init;

{Write Init Value to Output Address}

Output_Byte

:= Init;

{Put Init value In the Output_Byte Var}

END; {Set_Start}

This function must be the first one used, because all other functions assume that the variables have been set.

The Procedure, Set_IRQ_OFF, tells the parallel port not to generate any interrupts. This should be called immediately after Set_Start. It is defined as:

12

PPIO2899 Manual

B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104

Image 14
Contents Not Recommended for New Installations Table of Contents Introduction Packing List PC Parallel Port Description Page BIT PPIO2899 Manual Ppio Description & Connection PPIO2899 Manual Controlling the Ppio Using Gwbasic Bit Force I/O on Force I/O OFF Low High Page Controlling the Ppio Using Pascal BeginElse Mask Value Function OutputBit BitNumberBYTE Byte Procedure SetOutputBit BitNumber,OutputBYTE XOR Controlling the Ppio Using C Void SetIRQOffvoid Outport ControlAddress Mask Value Page Page New PPIO2899 Manual Page Interfacing to the Ppio PPIO2899 Manual Example USE of the Ppio Page REM IB is the Input Byte and OB is the Output Byte Hexadecimal Numbers AppendixBinary Numbers