Calibre UK ICA93LV user manual Using the Utilities, Routines 1. I2C Setup/Initialisation Routine

Page 7

5.Using the Utilities

Each utility is documented in a standard format, which lists its name, usage, function, 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.I2C Setup/Initialisation Routine

Name:

setup(base, own, sclk)

Usage:

setup(base, own, sclk);

Function:

procedure to set up I2C Communications Adapter.

Parameters are:

 

 

 

int base

base address of adapter set by links on circuit board.

int own

I2C 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 Write to address 0xAE

 

and a Read to address 0xAF. Be sure not to select an address that is already in

 

use by any other device in your I2C system. If own = 0x00 the adapter will monitor

 

all I2C bus information but will not affect any data transfers, thus acting as a bus

 

monitor.

 

 

int sclk

the SCL clock rate (bit rate for I2C serial bus).

 

 

 

 

 

Value of sclk

Approximate SCL (kHz)

 

 

0

90

 

 

1

45

 

 

2

11

 

 

3

1.5

 

 

 

 

 

Value Returned:none.

I2C status on exit from routine:

 

The I2C Communications Adapter will have the serial interface enabled; also data

 

reception acknowledge will be enabled. The status register will contain 0x81

 

(assuming that no other masters exist on the I2C system, if this is not the case

 

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 I2C 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(“I2C Communications Adapter initialised\n”);

}

/* This will set up the I2C Communications Adapter with a base */ /* address of 0x310, an I2C slave address of 0xAE and a SCL */ /* clock rate of approximately 45KHz */

5.1.2.I2C Status Checking Routine

Name:

getstatus(controladdress)

Usage:

status = getstatus(controladdress);

Function:

function to read status register of I2C Communications Adapter.

Revision 1.7

Page 6 of 27

09/12/1999

 

Image 7
Contents ICA93LV ContentsPacking List IntroductionSetting the Adapter Base Address Configuring the AdapterWait State Generator Bus Termination and Protection Installing the AdapterBus Capacitance Limitations/Cable Choice Connecting the Adapter to your System Connector PinoutNormal/Long Distance Mode Variable Voltage Bus Power SupplyTurboBASIC Library/Programs Getting Started Resetting the AdapterIntroduction to the Utilities Library/ProgramsRoutines 1. I2C Setup/Initialisation Routine Using the Utilities2. I2C Status Checking Routine 3. I2C Address and Start Sending Routine 4. I2C Read Data Byte from Slave Routine Send an I2C Stop Routine Write Data Byte to Slave Routine7. I2C Restart and Address Sending Routine TurboBASIC Routines 1. I2C Setup/Initialisation Routines2. I2C Status Checking Routine 3. I2C Address and Start Sending Routine Write Data Byte to Slave Routine 7. I2C Restart and Address Sending Routine Visual Basic 3.0 function SetupSendaddress Sendstop SendaddressRestart Sendbytes GetstatusGetbytes Slavelastbyte Further Information Real-Time Bus Monitor BUS ErrorBit 5 The STS Bit Appendix a I2C Communications Adapter Status CodesBit 7 MSB The PIN Bit Bit 6 Not UsedAppendix B I2C Communications Adapter Control Codes DOS Software Questions Question Do you have software to talk to my........?Hkeylocalmachine System