serial ppi manual eng - innovative electronics · 2 1. introduction pc-link serial ppi is 40 bits...

21
Serial PPI Trademarks & Copyright AT, IBM, PC, and PC-DOS are trademarks of International Business Machines Corporation. MS-DOS and Windows are registered trademarks of Microsoft Corporation. Pentium is a registered trademark of Intel Corporation. Borland Delphi is a copyright of Inprise Corporation. Turbo Pascal is a copyright of Borland International Incorporated. PC PC PC PC- - -Link Link Link Link Serial (COM) Port Parallel (LPT) Port USB Firewire ISA slot PCI slot

Upload: nguyenthuan

Post on 03-May-2019

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

Serial PPI

Trademarks & Copyright

AT, IBM, PC, and PC-DOS are trademarks of International Business Machines

Corporation.

MS-DOS and Windows are registered trademarks of Microsoft Corporation.

Pentium is a registered trademark of Intel Corporation.

Borland Delphi is a copyright of Inprise Corporation.

Turbo Pascal is a copyright of Borland International Incorporated.

PCPCPCPC----LinkLinkLinkLink

Serial (COM) Port Parallel (LPT) Port USB Firewire ISA slot PCI slot √√√√

Page 2: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

1

Contents

1.Introduction........................................................................................................ 1

1.1. SERIAL PPI External Specification................................................................ 1

1.2. SERIAL PPI Internal Specification................................................................. 1

1.3. System Requirements...................................................................................... 1

2. SERIAL PPI Hardware................................................................................... 2

2.1. SERIAL PPI Layout ....................................................................................... 2

2.2. Port Specification and Pinout.......................................................................... 2

2.3. SERIAL PPI Connection with Computer ...................................................... 3

2.4. Testing SERIAL PPI with SERPPI.EXE ....................................................... 3

2.5. Testing SERIAL PPI with PASPPI.EXE ....................................................... 3

3. SERIAL PPI Software.................................................................................... 3

3.1. UART RS-232 Specification........................................................................... 3

3.2. Command........................................................................................................ 4

3.2.1. Byte Transfer ............................................................................................... 4

3.2.2. Bit Set/Reset................................................................................................. 5

3.2.3. Counter......................................................................................................... 7

3.2.4. Baud Rate..................................................................................................... 8

3.3. DLL Routine and TPU.................................................................................... 8

3.4. Application Example and Program................................................................. 13

3.5. Program Structure........................................................................................... 15

Appendix

A. SERIAL PPI Schematic.................................................................................... 17

B. SERIAL PPI Protocol ....................................................................................... 18

Page 3: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

2

1. INTRODUCTION

PC-Link SERIAL PPI is 40 bits input/output lines controller through UART

RS-232 interface that can be connected directly to computer. Application of

PC-Link SERIAL PPI for examples are LED display controller, switches

monitor, pulse counter, etc.

1.1. SERIAL PPI EXTERNAL SPECIFICATION

SERIAL PPI has following external specification:

• UART RS-232 interface.

• 4-baud rates choices.

• 16-bit CMOS level I/O lines (Port 1 and Port 2).

• 24-bit CMOS level Programmable Peripheral Interface 82C55 (Port A, Port

B, and Port C).

• Two 16 bit CMOS level Counter (Counter 0 and Counter 1).

• 12 VDC input power supply.

• Voltage regulator with 5 VDC output.

1.2. SERIAL PPI INTERNAL SPECIFICATION

In SERIAL PPI UART communication exist Protocol Layer.

UART Protocol Layer is a layer utilized to arrange all data traffics and have

been arranged according to their function into sub routines packages.

List of API Command is in section 3.2.

1.3. SYSTEM REQUIREMENTS

Hardware:

• PC AT Pentium® IBM Compatible with Serial Port (COM1 / COM2).

• CD-ROM Drive.

• Minimum 2 MB free hard disk space.

Software:

• MS-DOS®, PC-DOS™, Windows® 9x or higher.

• Turbo© Pascal 7.0 or Borland© Delphi 5.0 or higher.

• Files in CD:

SERPPI.EXE, PASPPI.EXE, SERLIB.DLL, SERPAS.TPU, MANUAL

SERIAL PPI.PDF, QUICK START SERIAL PPI.PDF, 89S52.PDF,

82C55.PDF

Page 4: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

3

2. SERIAL PPI HARDWARE

2.1. SERIAL PPI LAYOUT

2.2. PORT SPECIFICATION AND PINOUT

J3 Pinout J4 Pinout

Port 1, 2, Counter 0, and Counter 1 specifications are as follow:

Symbol Parameter Typical Units

IOL Output Low Current 1.6 mA

IOH Output High Current -10 µA

IOL maximum per pin should not exceed 10 mA.

The sum of all IOL each port should not exceed 15 mA.

The sum of all IOL, for all port, should not exceed 71 mA.

Page 5: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

4

Port A, B, and C specifications are as follow:

Symbol Parameter Typical Units

IOL Output Low Current 2.5 mA

IOH Output High Current -100 µA

Further description can be seen at IC datasheet.

2.3. SERIAL PPI CONNECTION WITH COMPUTER

SERIAL PPI can be connected with computer COM port or with other

controller, which also have UART RS-232 interface. Please pay attention on

the communication lines connection.

2.4. TESTING SERIAL PPI WITH SERPPI.EXE

• Connect serial cable between SERIAL PPI and computer.

• Connect output device (for example LED circuit) to SERIAL PPI port.

• Connect power supply. Do not forget to connect Ground reference

between additional circuits with SERIAL PPI Ground.

• Run SERPPI.EXE program (under Windows®); choose which COM is

use and press Start button. LED’s connected to SERIAL PPI port will

light in sequences.

2.5. TESTING SERIAL PPI WITH PASPPI.EXE

• Connect serial cable between SERIAL PPI and computer.

• Connect output device (for example LED circuit) to SERIAL PPI port.

• Connect power supply. Do not forget to connect Ground reference

between additional circuits with SERIAL PPI Ground.

• Run PASPPI.EXE program (under DOS), type which COM is use and

press Enter. LED’s connected to SERIAL PPI port will light in

sequences.

3. SERIAL PPI SOFTWARE

Time needed by SERIAL PPI from power up until ready to operate (Start-up

Time) = 25 ms.

3.1. UART RS-232 SPECIFICATION

By default, UART RS-232 communication work with Baud Rate 9600 bps, 8

Data Bit, No Parity Bit, 1 Stop Bit, No Flow Control. Other Baud rate

option can be seen at section 3.2.4.

Computer COM Port

DB9 Male

SERIAL PPI

RJ11 Female

RTS (Pin 7) RTS (Pin 2)

GND (Pin 5) GND (Pin 3)

TX (Pin 3) TX (Pin 4)

RX (Pin 2) RX (Pin 5)

J1 Front View

Page 6: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

5

3.2. COMMAND

All data transaction always started by sending Command to SERIAL PPI.

M2 M1 M0 MODE

0 0 0 Not used

0 0 1 Byte Transfer

0 1 0 Bit Set/Reset

0 1 1 Counter

1 0 0 Baud Rate

1 1 X Not used

3.2.1. BYTE TRANSFER

Command for Byte Transfer will access one of Port 1, Port 2, Port A, Port B,

Port C, or Control Word. Accessing more than one port at the same time is not

allowed.

Writing/output process and reading/input process differentiate by R/W. R/W

given value “1” for reading process from port and given value “0” for writing

process to port.

Reading process will be follow by one byte containing port reading result

which sent by SERIAL PPI module. Writing process must be follow by one

byte, which will be sent to port.

Mode P2 P1 A1 A0 R/W Process

0 0 0 0 0 Write to Port A

0 0 0 0 1 Read from Port A

0 0 0 1 0 Write to Port B

0 0 0 1 1 Read from Port B

0 0 1 0 0 Write to Port C

0 0 1 0 1 Read from Port C

0 0 1 1 0 Write to Control Word

0 0 1 1 1 Not used

0 1 0 0 0 Write to Port 1

001

0 1 0 0 1 Read from Port 1

Page 7: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

6

Mode P2 P1 A1 A0 R/W Process

0 1 0 1 X Not used

0 1 1 X X Not used

1 0 0 0 0 Write to Port 2

1 0 0 0 1 Read from Port 2

1 0 0 1 X Not used

1 0 1 X X Not used

001

1 1 X X X Not used

By default, condition of all ports at startup is:

- Port 1 and Port 2: as input, value FFH

- Port A, Port B, Port C: un-programmed as input or output

To program Port A, B, and C, initiation must be done by sending 1 byte to

Control Word before using the port.

MSB (Most Significant Bit) LSB (Least Significant Bit)

D7 D6 D5 D4 D3 D2 D1 D0

Symbol Function

D7 Set Flag; give value 1 for active PPI Port.

D6 & D5 Mode Select for Port A and C Upper (bit 7 – bit 4),

give value 00 for mode 0, 01 for mode 1, and 10 or 11

for mode 2. Usually, mode 0 is use (value 00).

D4 Port A, give value 1 for input and give value 0 for

output.

D3 Port C Upper, give value 1 for input and give value 0

for output

D2 Mode Select for Port B and C Lower (bit 3 – bit 0),

give value 0 for mode 0 and give value 1 for mode 1.

Usually, mode 0 is use(value 0).

D1 Port B, give value 1 for input and give value 0 for

output.

D0 Port C Lower, give value 1 for input and give value 0

for output.

To use other mode, see more complete description in 82C55 datasheet.

Beside byte access, PPI Port can be access per bit (Bit Set/Reset). Bit access

limited only for Port C and only as output. Although using Port C, bit access

does not mean direct access to Port C address. Bit access can be done by send

1 byte to Control Word.

MSB LSB

D7 D6 D5 D4 D3 D2 D1 D0

Page 8: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

7

Symbol Function

D7 Set Flag, give value 0 for activate bit access.

D6, D5, D4 Don’t care (can be given value 0 or 1). Value 0

recommended.

D3, D2, D1 Bit Select to determine which bit on Port C will be

accessed. More completed description shown by Table

below.

D0 Bit Set/Reset for Port C. Give value 1 to Set (give logic

1 to bit) and value 0 to Reset (give logic 0 to bit).

Bit of Port C

7 6 5 4 3 2 1 0

D3 1 1 1 1 0 0 0 0

D2 1 1 0 0 1 1 0 0

D1 1 0 1 0 1 0 1 0

3.2.2. BIT SET/RESET

Bit Set/Reset command will write to Port 1 or Port 2 bit.

Bit selection determine by D0, D1, and D2 value. Bit value that will be written

determine by V.

D2 D1 D0 Bit accessed

0 0 0 Bit 0

0 0 1 Bit 1

0 1 0 Bit 2

0 1 1 Bit 3

1 0 0 Bit 4

1 0 1 Bit 5

1 1 0 Bit 6

1 1 1 Bit 7

Mode P2/P1 D2 D1 D0 V Process

0 X X X 0 Clear/Reset (give logic 0)

to Port 1 Bit

0 X X X 1 Set (give logic 1)

to Port 1 Bit

1 X X X 0 Clear/Reset (give logic 0)

to Port 2 Bit

010

1 X X X 1 Set (give logic 1)

to Port 2 Bit

Page 9: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

8

3.2.3. COUNTER

Counter command will access Counter 0 or Counter 1.

Start and Stop function is to activate/enable or deactivate/disable counter and

only work if Init have been given value 0.

Counter 0 and Counter 1 register will increase if their correlated pin (T0 or T1)

receives a signal with following timing diagram.

Symbol Parameter Minimum Units

tH Signal High “1” Time Duration before

Transition

0,55 µs

tL Signal Low “0” Time Duration before

Transition

0,55 µs

Read Command, Get Counter Data will be follow by two-byte containing

counter port reading result, which sent by SERIAL PPI module. The first data

byte is the Least Significant Byte, while the second data byte is the Most

Significant Byte.

Mode 00 C1/C0 GET/INIT START/STOP Process

00 0 0 0 Deactivate/Disable

Counter 0

00 0 0 1 Activate/Enable

Counter 0

00 0 1 0 Get Counter 0 Data

00 0 1 1 Not used

00 1 0 0 Deactivate/Disable

Counter 1

00 1 0 1 Activate/Enable

Counter 1

00 1 1 0 Get Counter 1 Data

00 1 1 1 Not used

01 X X X Not used

011

1X X X X Not used

By default, initial condition of Counter 0 and Counter 1 is deactivate/disable.

Input Signal

Page 10: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

9

3.2.4. BAUD RATE

Baud Rate Command will activate one of the Baud Rate settings.

Baud Rate setting selection determine by D0, D1, and D2 value.

Mode 00 D2 D1 D0 Baud Rate

00 0 0 0 9600 bps

00 0 0 1 19200 bps

00 0 1 0 38400 bps

00 0 1 1 57600 bps

00 1 0 0 115200 bps

01 1 X 1 Not used

100

1X X X X Not used

By default, initial baud rate value is:

- Baud Rate : 9600 bps

3.3. DLL ROUTINE AND TPU

SERIAL PPI have library in the form of SERLIB.DLL file, which can be use

by programming language that can access the file (for example Borland©

Delphi, Borland© C++, etc). Beside that, SERIAL PPI also have a unit in the

form of SERPAS.TPU file, which can be use by Turbo Pascal programming

language. Both file can simplified user programming.

The following are routines in SERLIB.DLL and SERPAS.TPU:

IOFlag

Function : Check the last communication status

Type : Function

Input : -

Output : IOFlag Type : Boolean

Description : -

Method : Call this routine to check whether SERIAL PPI has replay

with Acknowledge Code (FAH) on the last communication.

If the last command replied with FAH by SERIAL PPI, then

IOFlag value = True.

If the last command not replied with FAH by SERIAL PPI,

then IOFlag value = False.

COMBaud(Rate)

Function : Change baud rate on computer COM port.

Type : Function

Input : Rate Type : Longint

Page 11: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

10

Output : COMBaud Type : Boolean

Description : Valid rate value = 9600, 19200, 38400, 57600, and 115200.

Calling on this routine only change computer baud rate,

SERIAL PPI baud rate not change.

Method : Fill Rate value then call this routine like Example.

If Rate value is valid, then baud rate will change and

COMBaud value = True.

If Rate value not valid, then baud rate will not change and

COMBaud value = False.

Example : COMBaud(19200) will change computer baud rate to 19200

bps.

DeviceBaud(Rate)

Function : Change SERIAL PPI and computer COM port baud rate.

Type : Function

Input : Rate Type : Longint

Output : DeviceBaud Type : Boolean

Description : Valid rate value = 9600, 19200, 38400, 57600, and 115200.

Calling of this routine use the previous baud rate,

Calling on this routine will change SERIAL PPI baud rate and

computer baud rate.

Method : Fill Rate value then call this routine like Example.

If Rate value is valid and SERIAL PPI replied the command,

then baud rate will change and DeviceBaud value = True.

If Rate value is not valid or SERIAL PPI do not replay the

command, then baud rate will not change and DeviceBaud

value = False.

Example : DeviceBaud(19200) will change computer and SERIAL PPI

baud rate to 19200 bps.

CountStatus(CounterSelect, Run)

Function : Start or Stop Counter.

Type : Function

Input : CounterSelect Type : Byte

Run Type : Boolean

Output : CountStatus Type : Boolean

Description : Valid CounterSelect value = 0 and 1.

Method : Select which Counter will be activate by filling CounterSelect.

If Run given True value, then selected Counter will be

activated and SERIAL PPI can read input Counter.

If Run given False value, then selected Counter will be

deactivated and SERIAL PPI cannot read input Counter.

If CounterSelect value is valid and SERIAL PPI replied the

command, then Counter condition will change and

CountStatus value = True.

If CounterSelect value is not valid or SERIAL PPI do not

replay the command, then Counter condition will not change

and CountStatus value = False.

Example : CountStatus(0,True) will run Counter 0.

Page 12: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

11

CountRead(CounterSelect)

Function : Read Counter value.

Type : Function

Input : CounterSelect Type : Byte

Output : CountRead Type : Word

Description : Valid CounterSelect value is 0 and 1.

Method : Select which Counter will be read by filling CounterSelect.

If CounterSelect value is valid and SERIAL PPI replied the

command, then Selected Counter value will be in CountRead

and SERIAL PPI internal register will return to 0 value.

If CounterSelect value is not valid or SERIAL PPI do not

replay the command, then CountRead value = 0 and SERIAL

PPI internal register will not return to 0 value.

Example : CountRead(1) will read Counter 1 value.

PortWrite(IOport, DataOut)

Function : Write data to Port.

Type : Function

Input : IOport Type : String

DataOut Type : Byte

Output : PortWrite Type : Boolean

Description : Valid IOport value = ‘1’, ‘2’, ‘CW’ or ‘cw’, ‘A’ or ’a’, ‘B’ or

‘b’, and ‘C’ or ‘c’.

Write to CW (Control Word) determine Port A, B, and C

mode or to do Bit Set/Reset for Port C.

Write to Port A, B, or C are allowed if the port configured as

output.

Method : Select which Port to be access by filling IOport.

Data to be sending to Port is filled to DataOut.

If IOport value is valid and SERIAL PPI replied the

command, then DataOut value will be send to Port and

PortWrite value = True.

If IOport value is not valid or SERIAL PPI do not reply the

command, then DataOut value will not send to Port and

PortWrite value = False.

Example : PortWrite(‘1’,20) will write byte value 20 to Port 1.

PortRead(IOport)

Function : Read from Port.

Type : Function

Input : IOport Type : String

Output : PortRead Type : Byte

Description : Valid IOport value = ‘1’, ‘2’, ‘CW’ or ‘cw’, ‘A’ or ’a’, ‘B’ or

‘b’, and ‘C’ or ‘c’.

When reading Port 1 and 2, all Port bit will be given logic = 1

before reading the Port.

Read from Port A, B, or C is allowed if the port configured as

input.

Method : Select which Port to be access by filling IOport.

Page 13: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

12

If IOport value is valid and SERIAL PPI replied the

command, then port read result value would be in PortRead.

If IOport value is not valid or SERIAL PPI do not replay the

command, then PortRead value = 0.

Example : PortRead(‘2’) will read Port 2.

BitWrite(IOport, BitSelect, SetReset)

Function : Give logic 0 or 1 to Port 1 or Port 2 bit.

Type : Function

Input : IOport Type : Byte

BitSelect Type : Byte

SetReset Type : Boolean

Output : BitWrite Type : Boolean

Description : Valid IOport value = 1 and 2.

Valid BitSelect value = 0, 1, 2, 3, 4, 5, 6, and 7.

Method : Select which Port to be access by filling IOport.

Select which Bit to be access by filling BitSelect.

If SetReset value = True, then Bit logic = 1.

If SetReset value = False, then Bit logic = 0.

If IOport or BitSelect value is valid and SERIAL PPI replied

the command, then BitWrite value = True.

If IOport or BitSelect value is not valid and SERIAL PPI do

not replay the command, then BitWrite value = False.

Example : BitWrite(1,5,True) will give logic 1 to P1.5.

COMSetPort(PortSer)

Function : Select COM port.

Type : Function

Input : PortSer Type : String

Output : COMSetPort Type : Boolean

Description : Valid PortSer value = ‘COMn’ where n is COM port number.

PortSer value usually only ‘COM1’ and ‘COM2’, but there are

some computer who have ‘COM3’ or more.

This Routine only exist in SERLIB.DLL.

Method : Use this routine to select COM port before open it.

If this routine not use before opening COM port, then COM

Port use is COM1.

If PortSer value is valid, then COMSetPort value = True.

If PortSer value is not valid, then COMSetPort value = False.

Example : COMSetPort(‘COM2’) will select and open COM2.

Important!

If a COM port was opened and then change by COMSetPort routine, then

previous COM port will be closed automatically and a new port will be open

automatically.

Computer Baud Rate setting will not be change although COM port selection

change with COMSetPort.

Page 14: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

13

COMOpen(Stat)

Function : Open or Close COM port.

Type : Function

Input : Stat Type : Boolean

Output : COMOpen Type : Boolean

Description : This Routine only exist in SERLIB.DLL.

Method : If COMSetPort is not use before this routine, then, then COM

Port use is COM1.

If Stat value = True, then COM port will be open.

If Stat value = False, then COM port will be close.

If COM port open process can be done, COMOpen value =

True.

If COM port open/close process cannot be done or COM port

already closed, COMOpen value = False.

Example : COMOpen(True) akan membuka COM port.

Important!

Before COM port open or after COM port close, communication with SERIAL

PPI is not possible.

If a COM port opened and then change using COMSetPort routine, then

previous COM port will be close automatically and a new port will be open

automatically.

COMSet(PortSer)

Function : Select COM port.

Type : Procedure

Input : PortSer Type : String

Output : -

Description : Valid PortSer value = ‘COM1’ and ‘COM2’.

This Routine only exists in SERPAS.TPU.

Method : Select COM port by filling PortSer.

This routine only changes COM port to be use.

Example : COMInit(‘COM1’) will switch communication line to COM1.

COMInit(PortSer)

Function : Select COM port and do initialization.

Type : Procedure

Input : PortSer Type : String

Output : -

Description : Valid PortSer value = ‘COM1’ and ‘COM2’.

This Routine only exists in SERPAS.TPU.

Method : Select COM port by filling PortSer.

This routine will do initialization to selected COM port and set

computer baud rate to 9600 bps.

Example : COMInit(‘COM1’) will select COM 1 with 9600 bps baud

rate.

Important!

After COMInit, computer baud rate became 9600 bps, but SERIAL PPI baud

rate not change.

Page 15: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

14

DeviceReset

Function : Reset SERIAL PPI.

Type : Procedure

Input : -

Output : -

Description : -

Method : This routine will reset SERIAL PPI so the system return to

their startup condition (default).

Example : DeviceReset calling will reset computer and SERIAL PPI

baud rate to 9600 bps, Port 1 and Port 2 as input, Port A, Port

B, and Port C un-programmed, also both Counter disable.

3.4. APPLICATION EXAMPLE AND PROGRAM

Following is program listing in Borland© Delphi 5.0 to access Port 1 and

Counter 0.

//Write to Port 1

procedure TForm1.SendP1Click(Sender: TObject);

begin

if not PortWrite('1',dataout) then showmessage('Error');

if IOFlag then edit1.text:='Success' else

edit1.text:='Error';

end;

//Read from Port 1

procedure TForm1.ReceiveP1Click(Sender: TObject);

begin

r1.text:=inttohex(PortRead('1'),2);

if IOFlag then edit1.text:='Success' else

edit1.text:='Error';

end;

//Enable Counter 0

procedure TForm1.StartC0Click(Sender: TObject);

begin

if not CountStatus(0,True) then showmessage('Error');

if IOFlag then edit1.text:='Success' else

edit1.text:='Error';

end;

//Read Counter 0 register

procedure TForm1.GetC0Click(Sender: TObject);

begin

g0.text:=inttohex(CountRead(0),4);

if IOFlag then edit1.text:='Success' else

edit1.text:='Error';

end;

//Stop Counter 0

procedure TForm1.StopC0Click(Sender: TObject);

begin

if not CountStatus(0,False) then showmessage('Error');

if IOFlag then edit1.text:='Success' else

edit1.text:='Error';

end;

Page 16: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

15

Following is program listing in Turbo© Pascal 7.0 for bit accessing Port 2.7,

change baud rate, and reset the system.

{Toggle bit P2.7}

if p27 then

begin

if BitWrite(2,nl,false) then

begin

p27:=false;

textbackground(4);

clrscr;

end;

end

else

begin

if BitWrite(2,nl,true) then

begin

p27:=true;

textbackground(2);

clrscr;

end;

end;

{Change SERIAL PPI baud rate}

if ym=2 then DeviceBaud(19200)

{Change computer baud rate}

else if ym=3 then ComBaud(19200)

{Reset the system}

else if ym=4 then DeviceReset;

3.5. PROGRAM STRUCTURE

For a user who wishes to build an SERIAL PPI application program using

available routine, then SERLIB.DLL or SERPAS.TPU file must be use/call.

SERLIB.DLL is a library, which should always use for every SERIAL PPI

application programming Windows®.

SERPAS.TPU is a unit, which should always use for every SERIAL PPI

application programming using Pascal (under DOS).

SERIAL PPI program structure using Borland© Delphi 5.0 is as follow:

unit SERIALPPI;

interface

uses

Windows, Forms; {Fill according to requirement}

type

TForm1 = class(TForm)

. {User component/procedure/function declaration}

.

.

Page 17: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

16

private

{Private declarations}

public

{Public declarations}

end;

var

Form1: TForm1;

. {User program variable declaration}

.

.

implementation

{$R *.DFM}

. {SerLib.dll routine name}

stdcall; external 'SerLib.dll';

. {Call SerLib.dll routine as needed}

.

.

. {User program procedure/function}

.

.

end.

SERIAL PPI program structure using Turbo© Pascal 7.0 is as follow:

program SERIALPPI;

uses

Dos, Crt, Serpas; {Fill according to requirement}

const

. {User program constants declaration}

.

.

type

. {User component/procedure/function declaration}

.

.

var

. {User program variable declaration}

.

.

. {User program procedure/function}

.

.

. {Call SerPas.tpu routine as needed}

.

.

Page 18: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

17

begin

. {User main program}

.

.

end.

Thank you for your trust to use our product.

If there are any difficulty, suggestion or question concerning

this product please contact our technical support:

[email protected]

Page 19: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

17

APPENDIX A

SERIAL PPI SCHEMATIC

Page 20: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

18

APPENDIX B

SERIAL PPI PROTOCOL

Byte Sent by Master Byte Sent by Device

Recognized Command Acknowledge

Write Byte Acknowledge Data

Read Byte Acknowledge

Clear Bit Acknowledge

Page 21: Serial PPI Manual ENG - Innovative Electronics · 2 1. INTRODUCTION PC-Link SERIAL PPI is 40 bits input/output lines controller through UART RS-232 interface that can be connected

19

Set Bit Acknowledge

Start/Stop Counter Acknowledge

Get Counter Data Acknowledge

Lower Data Upper Data

Baud Rate Acknowledge

Un-Recognize Command Not Acknowledge

Baud rate change after

Acknowledge