Calibre UK IC Communication Adapter ICA93LV User Manual

Page 14

Advertising
background image

Revision 1.7

Page 13 of 27

09/12/1999

setnack%

this controls whether the I

2

C Communications Adapter transmits and

Acknowledge down the I

2

C 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.

I

2

C status on exit from routine:

The status of the I

2

C/ 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 I

2

C 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 I

2

C 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.

I

2

C status on exit from routine:

The status of the I

2

C 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 I

2

C 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 I

2

C Stop Routine

Name:

sendstop(controladdress%)

Usage:

call sendstop (controladdress%)

Advertising