Calibre UK ICA93LV user manual Write Data Byte to Slave Routine

Page 14

setnack%

this controls whether the I2C Communications Adapter transmits and

 

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 the LAST BUT ONE byte is to be

 

read, setnack% should be set to =1; in all other cases it must be set = 0. (In the

 

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:

 

<databyte%>

the function reads the byte of data and returns an integer equal to the value read.

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

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 Status Codes).

Example Usage:

(see also sample programs)

$include”i2c.inc”

‘* This contains the I2C routines *

baseaddr% = &h310

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

setnack% = 0

‘* Enable Acknowledge - only one byte is to be read *

‘* (see parameter descriptions) *

databyte% = FNreadbyte%(baseaddr%, setnack%) print “Data read was “;databyte%

‘* This will read a byte of data from a slave previously addressed by and with acknowledge already * ‘* disabled by sendaddress. After reading the data, acknowledge will be re-enabled.*

5.2.5.Write Data Byte to Slave Routine

Name:

writebyte(baseaddr%, databyte%)

Usage:

call writebyte(baseaddr%, databyte%)

Function:

procedure to write a byte of data to a slave device whose slave address has

 

already been sent by sendaddress.

Parameters are:

 

baseaddress%

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

 

board.

databyte%

the byte of data which is to be written to the slave device.

Value Returned:none.

 

I2C status on exit from routine:

 

The status of the I2C Communications Adapter will be &h00 - bus busy and data

 

in the data register transmitted successfully. (See Appendix A for details of

 

Status Codes).

Example Usage:

(see also sample programs)

$include “i2c.inc”

‘* This contains the I2C routines *

baseaddr% = &h310

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

databyte% = &h69

‘* Data byte which is to be transmitted*

call writebyte(baseaddr%, data byte%) print”Data has been transmitted”

‘* This will write a byte of data to a slave previously addressed by sendaddress. *

5.2.6.Send an I2C Stop Routine

Name:

sendstop(controladdress%)

Usage:

call sendstop (controladdress%)

Revision 1.7

Page 13 of 27

09/12/1999

 

Image 14
Contents Contents ICA93LVIntroduction Packing ListWait State Generator Configuring the AdapterSetting the Adapter Base Address 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/Programs2. I2C Status Checking Routine Using the UtilitiesRoutines 1. I2C Setup/Initialisation 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 Restart SendaddressSendstop 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