Calibre UK PICA93LV user manual Sendaddress, Int I2CData

Page 25

CALIBRE

 

 

 

 

￿

 

 

 

 

￿

Parameters returned

int ErrCode.

 

 

If the transfer time out occurs error code 8004H is returned otherwise the

 

 

status is returned.

Prerequisites

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

 

 

sendaddress.

Functional description

The function writes the data to the adapter and then waits for it to be sent.

 

 

Should a time-out occur during the sending of the data then error code 8004H

 

 

is returned, otherwise the status is returned.

 

 

Writebyte is compatible with both master write and slave write modes.

4.4.7.

readbyte

 

 

 

Function specification

Int readbyte(int setnack)

Parameters are:

int setnack

 

 

This controls whether the Parallel 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 clear = 0.

Parameters returned

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

 

 

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.

4.4.8.

sendstop

 

 

 

Function specification

Int sendstop( )

Parameters are:

None.

Parameters returned

int 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 a 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.

Issue 1.3

Page 22

22/07/99

Image 25
Contents Calibre Copyright CalibreContents Introduction Configuring the AdapterGeneral Introduction Packing ListTypical PC Connection Installing the AdapterConnector Pinout Connecting the Adapter to Your SystemPower Supply Bus Capacitance Limitations\C\CLIB\SPICA.LIB Software Utilities\C\CLIB\CPICA.LIB \C\CLIB\MPICA.LIB\B\SOURCE\I2CINC.BAS DOS Qbasic Library/Programs\B\SOURCE\PROMREAD.BAS \B\SOURCE\PROMWRIT.BASWindows LIB/DLL Functions Routines Using the UtilitiesInt ownaddress Int sclkInt slaveaddress Int i2cstatusInt setnack Calibre Int i2cdata Calibre Int i2cstatus Number if the adapter is to read from the slave Ownaddress% Qbasic RoutinesSclk% I2cstatus%Slaveaddress% I2cdata% Setnack%See Appendix a for details status codes I2cstatus% Is to read from the slave Int baseaddress Libraries for Programming in Microsoft Windows EnvironmentsInt statuswait Int wrData Int ErrCodeSendaddress Address to be accessed via the I2C, e.g. A1H Int far *transferarray Int sendbytesint far *transferarrayInt bsent Int nobytesread Int getbytesint far *transferarraySlave using the adapter Further Information Appendix a Parallel I2C Communications Adapter Status Codes Bit 4 The Bus Error BER BitBit 7 MSB The Pending Interrupt Not PIN Bit Bit 6 Not UsedAppendix B Parallel I2C Communications Adapter Control Codes Most Commonly Asked I2C Questions Question Get corrupted transfers why is this?Question Do you have software to talk to my........? QuestionCode. Why? Please Email Your Query to