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