Calibre UK IC Communication Adapter ICA93LV User Manual

Revision 1.7 09/12/1999
ICA93LV
I2C Communications Adapter User Manual
Contents
1.1. Packing List 1
2. Configuring the Adapter 2
2.1. Setting the Adapter Base Address 2
2.2. Wait State Generator 2
2.3. Interrupt Generation 3
2.4. Bus Termination and Protection 3
2.5. Installing the Adapter 3
3. Connecting the Adapter to your System 4
3.1. Connector Pinout 4
3.2. Normal/Long Distance Mode 4
3.3. Bus Capacitance Limitations/Cable Choice 4
3.4. Variable Voltage Bus Power Supply 4
4.1. Resetting the Adapter 5
4.2. Introduction to the Utilities 5
5.1. C Routines 6
5.2. TurboBASIC Routines 10
5.3. DLLs for Programming in Microsoft Windows 3.X Environments 15
6. Further Information 21
7. The Real-Time Bus Monitor 22 Appendix A I
2
C Communications Adapter Status Codes 23
Appendix B – I
2
C Communications Adapter Control Codes 24
Appendix C - The Most Commonly Asked I
2
C Questions 25
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
Revision 1.7 Page 1 of 27 09/12/1999
1. Introduction
The I
2
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
2
C bi-directional
compatibility as either a master or slave. I
2
C connections are made via a 9 way “D” socket. T his product
complies with the requirements of EEC Directive 89/336 for EMC and is CE marked.
1.1. Packing List
Your I
2
C Communications Adapter is supplied with the following items:-
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.7 Page 2 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:
LK3 LK2 LK1 Start Address(Hex) 0 0 0 0310 0 0 1 0312 0 1 0 0314 0 1 1 0316 1 0 0 0318 1 0 1 031A 1 1 0 031C 1 1 1 031E
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.
If 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 10MHz Position 1 PC over 10MHz, up to 16MHz Position 2 PC over 16MHz, up to 20MHz Position 3 PC over 20 MHz Position 4
The best position is the minim um number of wait states 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 possible to pr ove the fault. For fur ther help regarding timings contact your ICA93 supplier for technical support. The standard configuration is with one Wait State selected.
Revision 1.7 Page 3 of 27 09/12/1999
Important Note: Due to the internal operation of the ICA93, it must not be accessed over t he PC bus (read or written) more t han once every nine of its own 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 sending or reception of any byte on the I
2
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:
LK5 position PC Interrupt NONE DISABLED 2IRQ2 3IRQ3 4IRQ4 7IRQ7
As can be seen, the card is capable of c onnecting to f our out of the eight available PC I/O inter rupts. 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
Normally the system to which the I
2
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 variable s upply on these lines. The standard conf iguration is with these resistors disconnected.
The SCL and SDA lines are protected by 100R series resistors before ex iting the adapter via the 9 way “D” socket. Upstream of the series resistor s, the SCL and SDA pins on the PCF8584 are pulled up with high value resistors (10K). These ensure that the I
2
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 trans ients. If these diodes are connected, the external I
2
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.7 Page 4 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:
Pin Normal Mode 10V 20V 30V 40V 5NC 6 SDA (Bi-directional) 7 +V Variable bus voltage 8 SCL (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 distance mode which the 5V only ICA90 model can operate in. This is the only incompatibility between the two models.
3.3. Bus Capacitance Limitations/Cable Choice
The maxim um allowable capacitance on the I
2
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 (see Sec tion 8 - Fur ther Inf orm ation for r eferenc es). Care should be tak en in choosing a length and type of interconnecting cable, which will not exceed this limit.
For most systems with a distance of a few metres between the I
2
C Communications Adapter and the target system, screened cable is NOT 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 m ay 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 circuitry 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 shor ting 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 supply for low and high level thresholds respectively.
The Links 6, 7, and 8 are factory set to VAR and
MUST NOT BE MOVED.
Your ICA93 has been factory set for use on 3.3V I
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.7 Page 5 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 TurboBASIC, which c an be used for setup and basic communications. This is a list of the DOS utilities supplied:
C Library/Programs
Procedure or File Name Subroutine Name Brief Functional Description
i2c.h setup Sets user defined initial conditions.
getstatus Reads status register. sendaddress Sends slave address, data transmission mode and start signal. sendstop Sends stop signal. writebyte Writes a byte of data to a previously specified address. readbyte Reads a byte of data from a previously specified address. restart Sends Restart and slave address of device, which is to be
communicated with, without sending a Stop.
count.c Sends a counting sequence of 0 to 99 to a seven segment
display driver. count.exe Executable version of above. ram.c Writes then reads back data from a series of RAM locations.
Checks for correct readback. ram.exe Executable version of above. setup.c Sets up typical initial conditions – Own Slave Address = AE
(Hex), SCL = 90KHz; assumes adapter’s base address = 0310
(Hex). setup.exe Executable version of above.
TurboBASIC Library/Programs
Procedure or File Name Subroutine Name Brief Functional Description i2c.inc setup Sets user defined initial conditions.
FNgetstatus% Reads status register. sendaddress Sends slave address, data transmission mode and start signal. sendstop Sends stop signal. writebyte Writes a byte of data to a previously specified address. FNreadbyte% Reads a byte of data from a previously specified address. restart Sends restart and slave address of device which is to be
communicated with, without sending a Stop. count.bas Sends a counting sequence of 0 to 99 to a seven segment
display driver. tbcount.exe Executable version of above. ram.bas Writes then reads back data from a series of RAM locations.
Checks for correct readback. tbram.exe Executable 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.7 Page 6 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
5.1.1. I
2
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 base base address of adapter set by links on circuit board. int own I
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 select an addr ess that is already in use by any other device in your I
2
C system. If own = 0x00 the adapter will monitor
all I
2
C bus information but will not aff ect any data transfers, thus acting as a bus
monitor.
int sclk the SCL clock rate (bit rate for I
2
C serial bus).
Value of sclk Approximate SCL (kHz) 090 145 211
31.5 Value Returned:none. I
2
C status on exit from routine:
The I
2
C Communications Adapter will have the serial interface enabled; als o data reception acknowledge will be enabled. The status register will contain 0x81 (assuming that no other m asters exist on the I
2
C system, if this is not the cas e 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 */
#include <i2c.h> /*This contains the I
2
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); printf(“I
2
C Communications Adapter initialised\n”); } /* This will set up the I
2
C Communications Adapter with a base */
/* address of 0x310, an I
2
C slave address of 0xAE and a SCL */
/* clock rate of approximately 45KHz */
5.1.2. I
2
C Status Checking Routine
Name: getstatus(controladdress) Usage: status = getstatus(controladdress); Function: function to read status register of I
2
C Communications Adapter.
Revision 1.7 Page 7 of 27 09/12/1999
Parameters are: int controladdress address of I
2
C control register. This is equal to 1+(base address of adapter set
by links on circuit board). Value Returned: int <status> where status is an integer from 0x00 to 0xF F which indicates the current status
of I
2
C Communications Adapter . See Appendix A for details of the s tatus values
returned. I
2
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 */ #include <i2c.h> /*This contains the I
2
C routines */ main {
int status, base, controladdress; base = 0x310; /*Adapter’s base address = 0x310 (hex) */ controladdress = base + 1; Status = getstatus (controladdress); printf(“I
2
C Communications Adapter Status = %x\n”, status); } /*This will read the I
2
C Communications Adapter’s current status */
5.1.3. I
2
C Address and Start Sending Routine
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: int base the base address of the I
2
C Communications Adapter set by links on circuit
board. int slv the slave address of the device which is to be communic ated with. This 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. int setnack this controls whether the I
2
C Communications Adapter transmits an
Acknowledge down the I
2
C Bus on reception of a byte. The last byte received during a transfer mus t 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 s ent 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. I
2
C status on exit from routine
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 */
#include <i2c.h> /* This contains the I
2
C routines */
main
Revision 1.7 Page 8 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); printf(“Start and I
2
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: int base The base address of the I
2
C Communications Adapter set by links on circuit
board.
int setnack This controls whether the I
2
C Communications Adapter transmits an
Acknowledge down the I
2
C Bus on reception of a byte. The last byte received during a transfer must not be ac knowledged, in all other cas es mus t be enabled. If setnack = 0 then acknowledge is enabled, if setnack = 1 then acknowledge is disabled. Therefore, if the LAST BUT O NE byte is to be read, setnack should be set to = 1; in all other cases it mus t 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.
I
2
C status on exit from routine:
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 for 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 */
#include <i2c.h> /* This contains the I
2
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);
}
Loading...
+ 18 hidden pages