ESA PCIDIOT PCI I/O Timer Card Manual
ESA PCIDIOT PCI I/O Timer Card Manual
1.0 INTRODUCTION:
ESA PCIDIOT card is a PCI based Digital Input/Output timer card for PC
compatible systems. The card contains two 8255 programmed peripheral
interface (PPI) which provide 48 programmable I/O lines for the user and one
8254 programmable interval timer which provide three programmable
counter/timers to the user.
ESA PCIDIOT can be plugged into any one of the free PCI slots of the system.
This card is accompanied by a Driver CD, which contains Drivers & supporting
files.
CARD SPECIFICATIONS:
8255 : Two Nos. – Provide 48 I/O lines
8254 : One No. - Provides
3 Timers OUT Lines
3 Timer GATE Lines
3 Timer CLK Lines
JUMPERS : Used for setting the Input clock selection to the timer.
Power Supply : The card draws power from the system itself. No
external Power Supply required.
ESA Ext.
PCIDIOT
Hardware
(Stepper Motor,
A/D Converters.)
PCI Slot
Digital I/O
End User
ESA PCIDIOT P.C
The 24 I/O lines of U5 are brought to J2, a 26-pin berg connector. The 24 I/O
lines of U6 are brought to J3, a 25-pin D-Type connector and also to J4, a 26-pin
berg connector. If required, user can buy from Electro Systems Associates Pvt.
Ltd., a 25-pin D type female adapter for J2.
The PIT, 8254 at U3 has three 16-bit programmable timers /counters and can
operate up to 2.0 MHz. The OUT, GATE and CLK lines of the PIT are brought to
J1, a 15-pin D-Type Connector. Please refer to Appendix C for all connector
details.
The jumpers JP1, JP2 and JP3 are used for connecting external or system clock
to the clock input of timer of 8254.
NOTE:
The GATE0, GATE1, GATE2 signals of the 8254 should be controlled by user as
per his requirements.
NOTE:
To use the ESA PCIDIOT card in Windows (98/NT/2000/XP) Environment user
need to install Windows driver software and library files available on the Driver
Software CD.
To use the card in DOS, please refer chapter 5.5 (DOS Application Development).
NOTE:
The user must have administrative privileges on the target computer in order
to install the driver for Windows 2000/XP/NT.
W
If user selects “Install the software automatically”, it will search for the suitable
drivers in local drives and external media. In Case it does not detect any suitable
driver, select “Install from a list or specific location”, you should then see the
following window.
(WindowsXP)
G:\Driver\wdreg –inf C:\windows\system32\drivers\windrvr6.inf install
(Windows 2000)
G:\Driver\wdreg –inf C:\winnt\system32\drivers\windrvr6.inf install
(Windows 98)
G:\Driver\wdreg16 –inf C:\windows\system32\drivers\windrvr6.inf install
NOTE: Windows 98 requires a reboot after Installation of the driver for proper
working of the ESA PCIDIOT card.
Batch files for the above are provided in the Drivers CD, file names are reg98.bat
(Windows 98), reg2k.bat (Windows 2000) and regXP.bat (Windows XP).
User has to take care of the Drive names in the batch file while running these
batch files.
NOTE:
Windows NT Operating Systems doesn’t support Plug & Play feature. User
has to take care of the driver installation for the card.
For installing the driver, Double click on “install.bat” or run “install.bat” from the
command window.
For uninstalling the driver, close all the applications that are using this driver.
Double click on “uninst.bat” or run “uninst.bat” from the command windows.
NOTE:
On Windows 2000/XP/NT, the inf files will be created with “oemXX.inf” under
“%windir%\inf”. To find the inf file corresponding to ESA PCIDIOT card, user
can search the INF directory for the “ESA PCIDIOT” as a search text.
PURPOSE
Closes the Device Handle and frees resources allocated for the Device which
was created by ESAPCIDIOT_Open() at start.
PROTOTYPE
void ESAPCIDIOT_Close(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
RETURN VALUE
None
EXAMPLE
ESAPCIDIOT_Close(1);
PURPOSE
Writes the data to the 8255-1 Command Register of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_82551CR(unsigned char CardNumber, unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on the ports.
RETURN VALUE
NONE
EXAMPLE
Write_82551CR(1,0x80);
PURPOSE
Writes the data to the 8255-1 PortA of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_82551PortA(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on the ports.
RETURN VALUE
NONE
EXAMPLE
Write_82551PortA(1,0x80);
PURPOSE
Writes the data to the 8255-1 PortB of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_82551PortB(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on the ports.
RETURN VALUE
NONE
EXAMPLE
Write_82551PortB(1,0x80);
PURPOSE
Writes the data to the 8255-1 PortC of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_82551PortC(unsigned char CardNumber, unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on the ports.
RETURN VALUE
NONE
EXAMPLE
Write_82551PortC(1,0x80);
PURPOSE
Reads the data from the 8255-1 PortA of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned char Read_82551PortA(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
RETURN VALUE
Returns the data read from the 8255-1 PortA of ESA PCIDIOT Hardware.
EXAMPLE
Data = Read_82551PortA(1);
PURPOSE
Reads the data from the 8255-1 PortB of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned char Read_82551PortB(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
RETURN VALUE
Returns the data read from the 8255-1 PortB of ESA PCIDIOT Hardware.
EXAMPLE
Data = Read_82551PortB(1);
PURPOSE
Reads the data from the 8255-1 PortC of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned char Read_82551PortC(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
RETURN VALUE
Returns the data read from the 8255-1 PortC of ESA PCIDIOT Hardware.
EXAMPLE
Data = Read_82551PortC(1);
PURPOSE
Writes the data to the 8255-2 Command Register of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_82552CR(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on the ports.
RETURN VALUE
NONE
EXAMPLE
Write_82552CR(1,0x80);
PURPOSE
Writes the data to the 8255-2 PortA of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_82552PortA(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on the ports.
RETURN VALUE
NONE
EXAMPLE
Write_82552PortA(1,0x80);
PURPOSE
Writes the data to the 8255-2 PortB of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_82552PortB(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on the ports.
RETURN VALUE
NONE
EXAMPLE
Write_82552PortB(1,0x80);
PURPOSE
Writes the data to the 8255-2 PortC of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_82552PortC(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on the ports.
RETURN VALUE
NONE
EXAMPLE
Write_82552PortC(1,0x80);
PURPOSE
Reads the data from the 8255-2 PortA of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned char Read_82552PortA(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
RETURN VALUE
Returns the data read from the 8255-2 PortA of ESA PCIDIOT Hardware.
EXAMPLE
Data = Read_82552PortA(1);
PURPOSE
Reads the data from the 8255-2 PortB of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned char Read_82552PortB(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
RETURN VALUE
Returns the data read from the 8255-2 PortB of ESA PCIDIOT Hardware.
EXAMPLE
Data = Read_82552PortB(1);
PURPOSE
Reads the data from the 8255-2 PortC of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned char Read_82552PortC(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
RETURN VALUE
Returns the data read from the 8255-2 PortC of ESA PCIDIOT Hardware.
EXAMPLE
Data = Read_82552PortC(1);
PURPOSE
Writes the data to the 8254 Command Register of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_8254CR(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on the command register.
RETURN VALUE
NONE
EXAMPLE
Write_8254CR(1,0x30);
PURPOSE
Reads the data from specified 8254 timers on the fly of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned short Latch_Timer(unsigned char CardNumber, unsigned char
Timerno)
PARAMETERS
RETURN VALUE
Returns the data read from the specified 8254 Timer of ESA PCIDIOT Hardware.
EXAMPLE
PURPOSE
Writes the data to the 8254 Timer0 of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_Timer0(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on Timer0.
RETURN VALUE
NONE
EXAMPLE
Write_Timer0(1,0x80);
PURPOSE
Writes the data to the 8254 Timer1 of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_Timer1(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on Timer1.
RETURN VALUE
NONE
EXAMPLE
Write_Timer1(1,0x80);
PURPOSE
Writes the data to the 8254 Timer2 of ESA PCIDIOT Hardware.
PROTOTYPE
void Write_Timer2(unsigned char CardNumber, unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
on Timer2.
RETURN VALUE
NONE
EXAMPLE
Write_Timer2(1,0x80);
PURPOSE
Reads the data from the 8254 Timer0 of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned char Read_Timer0(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
RETURN VALUE
Returns the data read from the 8254 Timer0 of ESA PCIDIOT Hardware.
EXAMPLE
Data = Read_Timer0(1);
PURPOSE
Reads the data from the 8254 Timer1 of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned char Read_Timer1(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
RETURN VALUE
Returns the data read from the 8254 Timer1 of ESA PCIDIOT Hardware.
EXAMPLE
Data = Read_Timer1(1);
PURPOSE
Reads the data from the 8254 Timer2 of ESA PCIDIOT Hardware.
PROTOTYPE
unsigned char Read_Timer2(unsigned char CardNumber)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
RETURN VALUE
Returns the data read from the 8254 Timer2 of ESA PCIDIOT Hardware.
EXAMPLE
Data = Read_Timer2(1);
PURPOSE
Write the BYTE data to the specified address. This address should be in the
address range of Selected Card resources. Use “Chkdiot” utility to know the Card
resources.
PROTOTYPE
void outportb(unsigned char CardNumber, unsigned int PortAddr, unsigned char
Data)
PARAMETERS
RETURN VALUE
NONE
EXAMPLE
Outportb(1,0xd803, 0x80);
PURPOSE
Reads the BYTE data from the specified address. This address should be in the
address range of Selected Card resources. Use “Chkdiot” utility to know the Card
resources.
PROTOTYPE
unsigned char inportb(unsigned char CardNumber, unsigned int PortAddr)
PARAMETERS
RETURN VALUE
Returns the data read from the specified address of ESA PCIDIOT Hardware.
EXAMPLE
Data = inportb(1,0x8000);
PURPOSE
Enables the interrupt on ESAPCIDIOT card.
PROTOTYPE
void IntEnable(unsigned char CardNumber, P9050_INT_HANDLER
funcIntHnadler,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
funcIntHandler P9050_INT_HANDLER Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
funcIntHandler Interrupt service routine to be executed,
when interrupt occurs.
Data Used for specifying to enable interrupt 1
or 2
RETURN VALUE
NONE
EXAMPLE
IntEnable(1, IntrRoutine,1); //Enabling Interrupt 1 LINT1
PURPOSE
Disbales the interrupts on ESAPCIDIOT Card.
PROTOTYPE
void IntDisable(void);
PARAMETERS
None
RETURN VALUE
None
EXAMPLE
IntDisable();
PURPOSE
Writes the data to the Interrupt control and status register of ESA PCIDIOT
Hardware.
PROTOTYPE
void Write_INTCSR(unsigned char CardNumber,unsigned char Data)
PARAMETERS
Name Type Input/Output
CardNumber unsigned char Input
Data unsigned char Input
DESCRIPTION
Name Description
CardNumber Used for specifying the number of the
card, on which the operation to be done.
Data Used for specifying the data to be written
to INTCSR register.
RETURN VALUE
NONE
EXAMPLE
Write_INTCSR(1,0x43);
4. Enter the Project name and location where project-working folder should be
created.
5. Click OK button.
6. You should then see the following Dialog Box.
4. Enter the Project name and location where project-working folder should be
created.
5. Click OK button.
6. You should then see the following Dialog Box.
2) Choose New Project from the File menu. You should then see the following
dialog.
A problem that plagues Windows NT/2000 and Windows XP is it's strict control
over I/O ports. Unlike Windows 9x & ME, Windows NT/2000/XP will cause an
exception (Privileged Instruction) if an attempt is made to access an IO port that a
user mode program is not privileged to talk too. Actually it's not Windows NT that
does this, but any 386 or higher processor running in protected mode.
Accessing I/O Ports in protected mode is governed by two events, The I/O
privilege level (IOPL) in the EFLAGS register and the I/O permission bit map of a
Task State Segment (TSS). Under Windows NT, there are only two I/O privilege
levels used, level 0 & level 3. User mode programs will run in privilege level 3,
while device drivers and the kernel will run in privilege level 0, commonly referred
to as ring 0. This allows the trusted operating system and drivers running in
kernel mode to access the ports, while preventing less trusted user mode
processes from touching the I/O ports and causing conflicts. All user mode
programs should talk to a device driver, which arbitrates access. The I/O
permission bitmap can be used to allow programs not privileged enough (I.e. user
mode programs) the ability to access certain I/O ports. When an I/O instruction is
executed, the processors will first check if the task is privileged enough to access
the ports. Should this be the case, the I/O instruction will be executed. However if
the task is not allowed to do I/O, the processor will then check the I/O permission
bitmap. The I/O permission bitmap, as the name suggests uses a single bit to
represent each I/O address. If the bit corresponding to a port is set, then the
instruction will generate an exception however if the bit is clear then the I/O
operation will proceed. This gives a means to allow certain processes to access
certain ports. There is one I/O permission bitmap per task.
1) Run the “Chkdiot” utility from Drivers CD to know the ESA PCIDOT Card
resources. This utility lists the
i) 8255-1 & 8255-2 Command Register, PortA, PortB & PortC Address
ii) 8254 Timer Command Register, Timer0, Timer1 & Timer2 Address.
iii) Number of ESA PCIDIOT Cards Existing.
2) Open the Turbo C editor and create a new file. Use the listed addresses
of the card resources with inportb() & outportb() libraries, which is
available under “dos.h”.
EXAMPLE:
#include <stdio.h>
#include <dos.h>
void main(void)
{
// Make 8255-1 all port outports
outportb(0xd803,0x80);
// Make 8255-2 all port imports
outportb(0xdc03,0x9b);
while (!kbhit())
{
outportb(0xd800,0x55);
if (inportb(0xdc00) == 0x55)
printf(“PortA Good”);
}
}
More Examples was given in the ESA PCIDIOT Drivers CD.
Note:- MASM32 installation pack can be download from the web. It is not in the
scope of our supply.
Please refer the examples given in MASM32 folder of Driver CD. “Makeit.bat”
contains the assembler and linker commands.
J2 – 26 Berg Connector: