5.3. DLLs for Programming in Microsoft Windows 3.X Environments15
6. Further Information21
7. The Real-Time Bus Monitor22
Appendix A I
Appendix B – I
Appendix C - The Most Commonly Asked I
2
C Communications Adapter Status Codes23
2
C Communications Adapter Control Codes24
2
C Questions25
Revision 1.7
09/12/1999
Calibre UK Limited
Cornwall House, Cornwall Terrace
Bradford, West Yorkshire, BD8 7JS, England
Tel No: (01274) 394125
Fax No: (01274) 730960
Email sales@calibreuk.com
web-site www.calibreuk.com
1.Introduction
2
The I
C Communications Adapter is a half length PC interface card designed to fit any IBM PC
compatible expansion slot. Based on the Philips PCF8584 bus controller, it featur es full I
compatibility as either a master or slave. I
2
C connections are made via a 9 way “D” sock et. This product
2
C bi-directional
complies with the requirements of EEC Directive 89/336 for EMC and is CE marked.
1.1.Packing List
2
C Communications Adapter is supplied with the following items:-
Your I
A.I
2
C CD ROM
B. The ICA93 plug-in card (the actual adapter)
TO AVOID DAMAGE TO THIS PRODUCT PLEASE BE SURE TO READ PAGE 7, SECTION 5.4
BEFORE USE
Revision 1.7Page 1 of 27
09/12/1999
2.Configuring the Adapter
NOTE:MANY COMPONENTS ON THE ADAPTER CARD ARE STATIC SENSITIVE.
OBSERVE NORMAL STATIC SENSITIVE PRECAUTIONS WHEN HANDLING THE
CARD!
The adapter is supplied in a standard configuration which should suit most applications.
However, some features are link selectable. Read the following section to change the
configuration.
The standard configuration is:
base address = 0310 (Hex)
number of wait States = 1
hardware interrupts disabled
bus termination & protection off
2.1.Setting the Adapter Base Address
The card occupies a pair of PC I/O addresses and responds to input/output commands. Set the hex
starting address of this pair using LK1, LK2 and LK3 within the following range:
The standard configuration is LK1-3 at “0” giving a start address of 0310 (Hex).
2.2.Wait State Generator
Data validity is assured by delaying the PC bus using the IOCHRDY signal. The number of wait states
imposed on the PC bus is link selectable from 1 to 4 using LK4.
The card is supplied with LK4 in the “1” position, which is suitable for machines up to 10 MHz clock rate.
your machine implements dynamic speed switching on I/O channel access (as do most good
PCs), position 1 is correct no matter what its clock speed.
If a PC with a faster clock is used which does not switch speed on I/O channel access, it may be
necessary to increase the number of cycles delay to achieve the same absolute time delay.
Use the following table as a guideline for choosing the right position for your machine:
PC up to 10MHzPosition 1
PC over 10MHz, up to 16MHzPosition 2
PC over 16MHz, up to 20MHzPosition 3
PC over 20 MHzPosition 4
The best position is the minim um number of wait st ates while maintaining data security. This can easily
be found by trial and error.
The ICA93 operates correctly in all 'well behaved' faster machines. In m ost cases jus t one wait state will
be fine in even the fastest of machines. However, some rogue PCs that do not obey correct I/O tim ing
may cause problems occasionally. If you suspect this is a problem, try using the adapter in another
computer if poss ible to prove the fault. For fur ther help regarding tim ings contact your ICA93 supplier for
technical support. The standard configuration is with one Wait State selected.
If
Revision 1.7Page 2 of 27
09/12/1999
Important Note: Due to the internal operation of the ICA93, it must not be accessed ov er the PC
bus (read or written) more t han once every nine of its ow n clock cycles. The ICA93 is clocked at
12MHz; therefore it MUST NOT be accessed more than once every 0.75 microseconds. If this
requirement is not observed operation may become erratic. This is usually only encountered in
very fast PCs, however it must be borne in mind when writing software if say the system hardware
might be updated in the future. When timing problems are encountered it is invariably this which
is causing the difficulties, not the selection of the number of wait states. This is automatically
controlled by the Windows DLLs, but must be checked by the programmer when using the DOS
routines.
2.3.Interrupt Generation
The adapter is designed for either polled or interrupt driven operation. Interrupts are generated after the
2
sending or reception of any byte on the I
C Bus. The pulse is negative going with a duration of approx .
100nS, the interrupt being signalled by the rising edge of this pulse.
Link 5 allows the selection of which PC interrupt line the card is connected to:
As can be seen, the card is capable of connecting to f our out of the eight available PC I/O interrupts. T he
final choice will depend on what other peripherals are connected to the PC.
The standard configuration is with the interrupts disabled, i.e. LK5 in the “NONE” position.
2.4.Bus Termination and Protection
2
Normally the system to which the I
C Communications Adapter is to be connected should already have
master pull up resistors f itted to the SCL and SDA lines. If this is not the case, LK10 and LK12 can be
used to connect 4K7 pull up resistors to the var iable supply on these lines. The standard conf iguration is
with these resistors disconnected.
The SCL and SDA lines are protected by 100R series resistors befor e exiting the adapter via the 9 way
“D” socket. Upstream of the series resis tors, the SCL and SDA pins on the PCF8584 are pulled up with
2
high value resistors (10K). These ensure that the I
C Bus is in a defined state even if no other devices are
connected. The standard configuration is with these resistors connected using LK9 and LK11
LK13 and LK14 connect optional protection diodes to the SCL and SDL lines. When selected, these lines
are clamped to the 0V and variable supply lines giving protection against tr ansients. If these diodes are
2
connected, the external I
C system will not function if the adapter is connected but not powered up. The
standard configuration is with these diodes disconnected.
2.5.Installing the Adapter
NOTE:BEFORE INSTALLING THE ADAPTER IN YOUR PC, OBSERVE ANY SAFETY
PRECAUTIONS GIVEN BY THE MANUFACTURER OF THE COMPUTER.
NORMAL ANTI-STATIC HANDLING PRECAUTIONS SHOULD BE OBSEVED TO
AVOID ANY DAMAGE TO THE ICA93 OR THE COMPUTER.
Switch off the power to the PC and remove the mains plug from its socket before opening the case.
Plug the adapter into any available slot. Ensure the fixing screw is replaced in the com puter rear panel to
hold the adapter firmly in place.
Close the case, reconnect the mains lead and switch on the computer.
Revision 1.7Page 3 of 27
09/12/1999
3.Connecting the Adapter to your System
3.1.Connector Pinout
All external connections are made via a 9 way “D” socket:
PinNormal Mode
10V
20V
30V
40V
5NC
6SDA (Bi-directional)
7+V Variable bus voltage
8SCL (Bi-directional)
9NC
NOTE:THE PINS MARKED NC MUST NOT BE CONNECTED IN NORMAL MODE.
3.2.Normal/Long Distance Mode
The ICA93 does NOT support the 4- wire long distanc e mode which the 5V only ICA90 model can oper ate
in. This is the only incompatibility between the two models.
3.3.Bus Capacitance Limitations/Cable Choice
2
The maxim um allowable capacitance on the I
C bus in normal mode depends on the value of the SCL
and SDA master pull-ups, but never exceeds 400pF. Refer to Phillips Technical Handbook Book 4 Parts
12a and 12b for further details (s ee Section 8 - F urther Inf orm ation f or r efer ences) . Care should be tak en
in choosing a length and type of interconnecting cable, which will not exceed this limit.
2
For most systems with a distance of a few metres between the I
C Communications Adapter and the
target system, screened cable is NO T recommended, as it is lik ely to introduce too much capacitance.
However, the EMC performance of an unscreened cable is always potentially poorer than a screened
one. The Adapter's EMC perform ance even with an unscreened cable is good - but this may not be true
of the target system! If you are in any doubt at to the best way to connect up your system with EMC in
mind please contact your supplier or Calibre for advice.
3.4.Variable Voltage Bus Power Supply
Pin 7 on the “D” connector is connected to the variable bus voltage power rail. Power for external circuitr y
can be drawn from here, but care should be taken never to short it to 0V or to exceed 250mA loading. It is
short circuit and overload protected by a self-res etting thermal fuse but prolonged s horting could cause
the ICA93 to generate an excessive amount of heat inside your computer.
When shipped to you, the bus voltage was pre-set at 3.3V for use with low voltage memories. You can
adjust the voltage between 2V and 6V by inserting a small screwdriver through the hole in the card
mounting bracket. As you adjust the voltage (you can monitor it by connecting a m eter to pin 7 of the bus
connector) the bus logic levels will track, keeping at 30% / 70% of s upply for low and high level thresholds
respectively.
The Links 6, 7, and 8 are factory set to VAR and
Your ICA93 has been factory set for use on 3.3V I
MUST NOT BE MOVED.
2
C bus systems. Use on 5V I2C bus systems
without adjusting the voltage control WILL CAUSE PERMANENT DAMAGE to the IC93. The fault is
factory detectable and you WILL BE CHARGED FOR THE REPAIR.
Revision 1.7Page 4 of 27
09/12/1999
4.Getting Started
4.1.Resetting the Adapter
A reset forces the adapter into a well defined state, ready for initialisation. T he card uses the s ame reset
line as the PC so either a power up or hard reset (press the <RESET> button on your PC) will suffice.
4.2.Introduction to the Utilities
The utilities supplied with the adapter contain simple DOS routines in both C and Tur boBASIC, which can
be used for setup and basic communications. This is a list of the DOS utilities supplied:
C Library/Programs
Procedure or
File NameSubroutine NameBrief Functional Description
i2c.hsetupSets user defined initial conditions.
getstatusReads status register.
sendaddressSends slave address, data transmission mode and start signal.
sendstopSends stop signal.
writebyteWrites a byte of data to a previously specified address.
readbyteReads a byte of data from a previously specified address.
restartSends Restart and slave address of device, which is to be
communicated with, without sending a Stop.
count.cSends a counting sequence of 0 to 99 to a seven segment
display driver.
count.exeExecutable version of above.
ram.cWrites then reads back data from a series of RAM locations.
Checks for correct readback.
ram.exeExecutable version of above.
setup.cSets up typical initial conditions – Own Slave Address = AE
Procedure or
File NameSubroutine NameBrief Functional Description
i2c.incsetupSets user defined initial conditions.
FNgetstatus%Reads status register.
sendaddressSends slave address, data transmission mode and start signal.
sendstopSends stop signal.
writebyteWrites a byte of data to a previously specified address.
FNreadbyte%Reads a byte of data from a previously specified address.
restartSends restart and slave address of device which is to be
communicated with, without sending a Stop.
count.basSends a counting sequence of 0 to 99 to a seven segment
display driver.
tbcount.exeExecutable version of above.
ram.basWrites then reads back data from a series of RAM locations.
Checks for correct readback.
tbram.exeExecutable version of above.
16 bit Windows DLLs f or use with Visual Basic 3.0 and Microsoft C++1.5 are included on the dis c. See
Section 7.3 for a detailed description of the routines available. All library functions listed for the DOS
routines are covered. Additionally some extra multiple operation functions are supplied.
Revision 1.7Page 5 of 27
09/12/1999
5.Using the Utilities
Each utility is documented in a standard form at, which lists its name, usage, f unction, and effect on the
adapter is given. Following a reset, the adapter should be setup prior to any data transfer.
5.1.C Routines
2
5.1.1.I
C Setup/Initialisation Routine
Name:setup(base, own, sclk)
Usage:setup(base, own, sclk);
Function:procedure to set up I
2
C Communications Adapter.
Parameters are:
int basebase address of adapter set by links on circuit board.
int ownI
2
C address to which the adapter is to respond in slave mode. This forms the
upper 7 bits of the 8 bit address; the lowest bit being the Read (1) or Write (0) bit.
This means that if own = 0x57, the card will respond to a W rite to address 0xAE
and a Read to address 0xAF. Be sure not to selec t an address that is already in
2
use by any other device in your I
2
all I
C bus information but will not aff ect any data transfers, thus acting as a bus
C system. If own = 0x00 the adapter will monitor
monitor.
int sclkthe SCL clock rate (bit rate for I
2
C serial bus).
Value of sclkApproximate SCL (kHz)
090
145
211
31.5
Value Returned:none.
2
I
C status on exit from routine:
2
The I
C Communications Adapter will have the serial interfac e enabled; also data
reception acknowledge will be enabled. The status register will contain 0x81
(assuming that no other m asters exist on the I
then the contents of the status register will also depend on externally generated
bus activity).
Example Usage: (see also sample programs)
#include <stdio.h>
#include <dos.h>/*Optional, but recommended if your compiler */
/*supports DOS I/O functions */
2
#include <i2c.h>/*This contains the I
C routines */
main
{
int base, own, sclk;
base = 0x310;/* Adapter’s base address = 0x310 (hex) */
own = 0x57;/* Own slave address set to 0x57 (hex) */
sclk = 1;/* Serial clock rate set to 45KHz */
setup(base, own sclk);
2
printf(“I
C Communications Adapter initialised\n”);
}
/* This will set up the I
/* address of 0x310, an I
2
C Communications Adapter with a base */
2
C slave address of 0xAE and a SCL */
/* clock rate of approximately 45KHz */
5.1.2.I
2
C Status Checking Routine
2
C system, if this is not the cas e
Name:getstatus(controladdress)
Usage:status = getstatus(controladdress);
Function:function to read status register of I
2
C Communications Adapter.
Revision 1.7Page 6 of 27
09/12/1999
Parameters are:
int controladdress address of I
by links on circuit board).
Value Returned:
2
C control register. This is equal to 1+(base address of adapter s et
int <status>where status is an integer from 0x00 to 0x FF which indicates the current status
2
C Communications Adapter . See Appendix A for details of the s tatus values
of I
returned.
2
I
C status on exit from routine:
The status of the I
2
C Communications Adapter will not be affected by using the
getstatus function.
Example Usage: (see also sample programs)
#include <stdio.h.>
#include <dos.h>/*Optional, but recommended if your compiler */
/*supports DOS I/O functions */
2
#include <i2c.h>/*This contains the I
C routines */
main
{
int status, base, controladdress;
base = 0x310;/*Adapter’s base address = 0x310 (hex) */
controladdress = base + 1;
Status = getstatus (controladdress);
2
printf(“I
C Communications Adapter Status = %x\n”, status);
}
/*This will read the I
5.1.3.I
2
C Address and Start Sending Routine
2
C Communications Adapter’s current status */
Name:sendaddress (base, slv, setnack)
Usage:sendaddress(base, slv, setnack)
Function:procedure to send Start and slave address of device that is to be com munic ated
with.
Parameters are:
2
int basethe base address of the I
C Communications Adapter set by links on circuit
board.
int slvthe slave address of the device which is to be communic ated with. T his will be an
even number if the adapter is to write to the slave, add 1 to get an odd num ber if
the adapter is to read from the slave.
2
int setnackthis controls whether the I
Acknowledge down the I
2
C Bus on reception of a byte. The last byte received
C Communications Adapter transmits an
during a transfer mu st not be acknowledged, in all other cases acknowledge is
enabled, if setnack = 1 then acknowledge is disabled. T herefore, if a read (odd
numbered) address is being sent AND only 1 byte is to be read, setnack should
be set to = 1; in all other cases it must be set = 0.
Value Returned:none.
2
C status on exit from routine
I
The status of the I
2
C/ the Communications Adapter will be either 0x00 - bus busy
and unread data in the data register or 0x80 - bus busy and no unread data in the
data register when a Start and Slave Address have been successfully transmitted
(see Appendix A for details of Status Codes).
Example Usage:(see also sample programs)
#include <stdio.h>
#include <dos.h>/* Adapter’s base address = 0x310 (hex) */
/* compiler supports DOS I/O functions */
2
#include <i2c.h>/* This contains the I
C routines */
main
Revision 1.7Page 7 of 27
09/12/1999
{
int base, slv, setnack;
base = 0x310;/* Adapter’s bas address = 0x310 (hex) */
slv = 0xa0;/* I
2
C Address of slave, this is a typical */
/* write for an I
2
C static RAM or EEPROM */
setnack = 0;/* Enable Acknowledge (see parameter */
/* descriptions) */
sendaddress(base, slv, setnack);
2
printf(“Start and I
C Slave Address sent\n”);
}
/* This will send a start and the I
2
C Slave Address of the device */
/* to be communicated with. */
5.1.4.I
2
C Read Data Byte from Slave Routine
Name:readbyte(base, setnack)
Usage:data = readbyte(base, setnack);
Function:To read a byte of data from a slave device whose slave address has already
been sent by sendaddress. Can be used to disable acknowledge after reading
data if it is the last but one byte to be read.
Note: First byte read after read-address is always that address and should be discarded. This byte
should be ignored when working out when to acknowledge/not acknowledge.
Parameters are:
2
int baseThe base address of the I
C Communications Adapter set by links on circuit
board.
int setnackThis controls whether the I
Acknowledge down the I
2
C Bus on reception of a byte. The last byte received
2
C Communications Adapter transmits an
during a transfer must not be ac knowledged, in all other cas es m ust be enabled.
If setnack = 0 then acknowledge is enabled, if setnack = 1 then acknowledge is
disabled. Therefore, if the LAST BUT ONE byte is to be read, setnack should be
set to = 1; in all other cases it mu st be set = 0. (in case of reading 1 byte only,
acknowledge will have been disabled by sendaddress and so should now be
enabled again after reading the data, hence setnack = 0 for reading a single byte
of data.)
Value Returned:
int <data>The function reads the byte of data and returns an integer equal to the value
read.
2
C status on exit from routine:
I
The status of the I
2
C Communications Adapter will be either 0x00 - bus busy and
unread data in the data register or 0x80 - bus busy and no unread data in the
data register depending on whether any more bytes of data have been
transmitted by the slave device which is being read. (See Appendix A f or details
of the status Codes).
Example Usage:(see also sample programs)
#include <stdio.h>
#include <dos.h>/* Optional, but recommended if your compiler */
/* supports DOS I/O functions */
2
#include <i2c.h>/* This contains the I
C functions */
main
{
int base, setnack, data;
base = 0x310;/* Adapter’s base address = 0x310 (hex) */
setnack = 0;/* Enable acknowledge - only one byte it to */
/* be read (see parameter descriptions) */
data = readbyte(base, setnack);
printf(“Data read was %x\n”, data);
}
Revision 1.7Page 8 of 27
09/12/1999
Loading...
+ 18 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.