Calibre UK ICA93LV user manual Sendaddress, Sendstop, Restart

Page 18

 

Setnack 1 for no acknowledge 0 for acknowledge.

Parameters returned

I2Cdata, the data read, if a time-out occurs the ErrCode 8005H is

 

returned.

Prerequisites

Adapter must be configured using setup, start and read address sent by

 

sendaddress.

Functional Description

If setnack is 1 the function writes 40H to the control register to establish

 

the correct acknowledge procedure. The data is read from the adapter.

 

IMPORTANT: SETNACK MUST = 1 WHEN READING THE LAST AND

 

THE LAST BUT ONE BYTES IN A SEQUENCE OF BYTES

 

SETNACK MUST = 0 FOR ALL OTHER READS. IF THIS FORMAT IS

 

NOT STRICTLY FOLLOWED THEN THE ADAPTER AND BUS WILL

 

NOT OPERATE CORRECTLY.

 

WHEN READING ANOTHER I2C DEVICE THE FIRST BYTE READ

 

USING THE READBYTE FUNCTION IS ALWAYS THE SLAVE

 

ADDRESS OF THAT DEVICE. THIS MUST BE READ AND

 

DISCARDED BEFORE THE REAL DATA CAN BE READ. DO NOT

 

COUNT THIS EXTRA READ WHEN CONSIDERING WHETHER OR

 

NOT TO ACKNOWLEDGE.

 

Should a time-out occur then an error code 8005H is returned, otherwise

 

the data is returned. Readbyte is compatible with both master read and

 

slave read modes.

sendstop

 

Function specification

Int sendstop ( )

Parameters returned

ErrCode. If the transfer time out occurs error code 8002H is returned

 

otherwise the status is returned.

Prerequisites

Adapter must be configured using setup. Should normally only be used

 

at the end of transmission. Correct acknowledge sequence must have

 

been applied if the transmission was a read.

Functional description

Instruct the adapter to send a stop code and wait for it to be sent. Should

 

a time-out occur during the sending of a stop then an error code 8002H

 

is returned, otherwise the status is returned.

restart

 

Function specification

Int restart (int slaveaddress, int setnack)

 

Slaveaddress is the address to be accessed via the I2C, e.g. A1H

 

Setnack 1 for no acknowledge 0 for acknowledge – see Functional

 

Description.

Parameters returned

ErrCode. If the transfer time out occurs error code 8003H is returned

 

otherwise the status is returned.

Prerequisites

Adapter must be configures using setup. A start and slave address must

 

have previously been sent using sendaddress. Usually a data pointer

 

would already have been written using writebyte.

Functional description

Sends a start code and the slave address specified and presets the

 

acknowledge status depending on the value of setnack. The

 

acknowledge is set ready for the data transfer after the address and

 

hence in read mode (odd address being sent) if only one byte is to be

 

read the setnack parameter must equal 1. If more than one byte is to be

 

read or if in write mode (even address being sent) then setnack must

 

equal 0.

 

The function waits for the address to be sent. Should a time-out occur

 

during the sending of an address then an error code 8003H is returned,

 

otherwise the status is returned.

Revision 1.7

Page 17 of 27

09/12/1999

 

Image 18
Contents Contents ICA93LVIntroduction Packing ListConfiguring the Adapter Setting the Adapter Base AddressWait State Generator Installing the Adapter Bus Termination and ProtectionVariable Voltage Bus Power Supply Connecting the Adapter to your System Connector PinoutNormal/Long Distance Mode Bus Capacitance Limitations/Cable ChoiceLibrary/Programs Getting Started Resetting the AdapterIntroduction to the Utilities 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 MonitorBit 6 Not Used Appendix a I2C Communications Adapter Status CodesBit 7 MSB The PIN Bit Bit 5 The STS BitAppendix B I2C Communications Adapter Control Codes Question Do you have software to talk to my........? DOS Software QuestionsHkeylocalmachine System