Calibre UK ICA93LV user manual 7. I2C Restart and Address Sending Routine

Page 15

Function:

procedure to send a Stop (end of communication signal) down the I2C Bus,

 

ending a transmission or reception with a slave that was address previously by

 

sendaddress.

Parameters are:

 

controladdress%

The address of the I2C Communications Adapter control register, equal to

 

1+(base address set by links on circuit board).

Value Returned:none.

 

I2C status on exit from routine:

The status of the I2C/ the Communications Adapter will be &h81 - bus idle and no unread/untransmitted data in the data register. Note - this may not be the case in a system where there is another master as well as the I2C Communications Adapter, since this other master may well have taken control of the bus by the time a program next uses getstatus to read the status register. (See Appendix A for details of Status Codes).

Example Usage: $include “i2c.inc” baseaddr% = &h310 controladdress% = baseaddr% + 1 call sendstop(controladdress%) print”Stop has been transmitted”

‘* This will write a stop to the I2C Bus*

(see also sample programs)

‘* This contains the I2C routines*

‘* Adapter’s base address = 310 (hex) * ‘* Control Register address *

5.2.7.I2C Restart and Address Sending Routine

Name:

restart(baseaddr%, slv% setnack%)

Usage:

call restart(baseaddr%, slv%, setnack%)

Function:

procedure to send a Restart and the slave address of device that is to be

 

communicated with, without a Stop having been sent at the end of the last

 

transmission/reception. This routine is particularly useful for reading memories

 

which must first have a data pointer written to them to select where the read is to

 

occur from, and must then have their read address sent with a Restart to

 

proceed with the read operation.

Parameters are:

 

baseaddr%

the base address of the I2C Communications Adapter set by links on circuit

 

board.

slv%

the slave address of the device which is to be communicated with. This will be an

 

even number if the communicated with. This will be an even number if the

 

adapter is to write to the slave, add 1 to get an odd number if the adapter is to

 

read from the slave.

setnack%

this controls whether the I2C Communications Adapter transmits an

 

Acknowledge down the I2C Bus on reception of a byte. The last byte received

 

during a transfer must not be acknowledged, in all other cases acknowledge

 

must be enabled. If setnack% = 0 then acknowledge is enabled, if setnack% = 1

 

then acknowledge is disabled. Therefore, 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.

 

I2C status on exit from routine:

 

The status of the I2C/ the Communications Adapter will be either &h00 - bus the

 

busy and unread data in the data register or &h80 - bus busy and no unread data

 

in the data register when a Restart and Salve Address have been successfully

 

transmitted (see Appendix

A for details of Status Codes).

Example Usage:

 

 

$include “i2c.inc”

‘* This contains the I2C routines*

 

baseaddr% = &h310

‘* Adapter’s base address = 310 (hex) *

Revision 1.7

 

Page 14 of 27

09/12/1999

 

 

Image 15
Contents ICA93LV ContentsPacking List IntroductionConfiguring the Adapter Setting the Adapter Base AddressWait 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/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 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 Sendaddress SendstopRestart 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