Calibre UK ICA93LV user manual 2. I2C Status Checking Routine

Page 12

Name:

setup (baseaddr%, own%, sclk%)

Usage:

call setup(baseaddr%, own%, sclk%)

Function:

procedure to set up I2C Communications Adapter.

Parameters are:

 

 

 

baseaddr%

base address of adapter set by links on circuit board.

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% = &h57, the card will respond to a Write to address

 

&hAF. Be sure not to select an address that is already in use by any other device

 

in your I2C system. If own% &h00 the adapter will monitor all I2C bus information

 

but will not affect any data transfers, thus acting as a bus monitor

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 &h81

 

(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 “i2c.inc”

‘* This contains the I2C routines*

baseaddr% = &h310

‘* Adapter’s base address = &h310 (hex) *

own% = &h57

‘* Own slave address set to &h57 (hex) *

sclk% = 1

‘* Serial clock rate set to 45KHz *

call setup(baseaddr%, own%, sclk%)

print”I2C Communications Adapter initialised”

‘* This will set up the I2C Communications Adapter with a base address * ‘* of &h310, an I2C slave address of &hAE and a SCL clock rate of *

‘* approximately 45KHz *

5.2.2.I2C Status Checking Routine

Name:

FNgetstatus%(Controladdress%)

Usage:

status% = FNgetstatus%(controladdress%)

Function:

function to read status register of I2C Communications Adapter.

Parameters are:

 

controladdress%

address of I2C control register. This is equal to 1+(base address of adapter set

 

by links on circuit board).

Value Returned:

 

<status%>

where status is an integer from &h00 to &hFF which indicates the current status

 

of the I2C communications Adapter. Appendix A for details of the status values

 

returned.

I2C status on exit from routine:

 

The status of the I2C Communications Adapter will not be affected by using the

 

FNgetstatus% function.

Example Usage:

(see also sample programs)

$include “i2c.inc”

‘* This contains the I2C routines *

Revision 1.7

Page 11 of 27

09/12/1999

 

Image 12
Contents Contents ICA93LVIntroduction Packing ListConfiguring the Adapter Setting the Adapter Base AddressWait State Generator Installing the Adapter Bus Termination and ProtectionConnecting the Adapter to your System Connector Pinout Normal/Long Distance ModeVariable Voltage Bus Power Supply Bus Capacitance Limitations/Cable ChoiceGetting Started Resetting the Adapter Introduction to the UtilitiesLibrary/Programs TurboBASIC Library/ProgramsUsing the Utilities Routines 1. I2C Setup/Initialisation Routine2. I2C Status Checking Routine 3. I2C Address and Start Sending Routine 4. I2C Read Data Byte from Slave Routine Write Data Byte to Slave Routine Send an I2C Stop RoutineTurboBASIC Routines 1. I2C Setup/Initialisation Routines 7. I2C Restart and Address Sending Routine2. I2C Status Checking Routine 3. I2C Address and Start Sending Routine Write Data Byte to Slave Routine 7. I2C Restart and Address Sending Routine Setup Visual Basic 3.0 functionSendaddress Sendaddress SendstopRestart Getstatus SendbytesGetbytes Slavelastbyte Further Information BUS Error Real-Time Bus MonitorAppendix a I2C Communications Adapter Status Codes Bit 7 MSB The PIN BitBit 6 Not Used Bit 5 The STS BitAppendix B I2C Communications Adapter Control Codes Question Do you have software to talk to my........? DOS Software QuestionsHkeylocalmachine System