Calibre UK PICA93LV user manual Int ErrCode, Int wrData

Page 24

CALIBRE

 

 

 

 

￿

 

 

 

 

￿

 

This is a period of time (in micro seconds) to wait for the required bus status.

 

If this time-out expires the I2C functions will exit returning an error code.

 

int sclk

 

 

 

 

This is the clock rate (bit rate for the I2C serial bus) when operating as a

 

master.

 

 

 

 

Value of sclk

Approximate SCL-KHz

 

0

90

 

 

 

1

45

 

 

 

2

11

 

 

 

3

1.5

 

 

Parameters returned

None.

 

 

 

Prerequisites

None.

 

 

 

Functional description

This function

characterises the PC and initialise adapter ready for I2C

 

transfers.

 

 

 

4.4.5.sendaddress

Function specification

Int sendaddress(int slaveaddress, int setnack)

Parameters are:

int slaveaddress

 

 

This is the address to be accessed via the I2C, e.g. A0H.

 

 

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

 

 

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

 

 

status is returned.

Prerequisites

The adapter must be configured for PC and application by running setup.

Functional description

The function waits for the bus to be free. Then sends the slave address with

 

 

the appropriate acknowledge.

 

 

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 8001H is returned, otherwise

 

 

the status is returned.

4.4.6.

writebyte

 

Function specification

Int writebyte(int wrData)

Parameters are:

int wrData

 

 

This is the byte of data to be written.

Issue 1.3

 

Page 21

22/07/99

Image 24
Contents Calibre Calibre CopyrightContents Configuring the Adapter IntroductionGeneral Introduction Packing ListInstalling the Adapter Typical PC ConnectionConnecting the Adapter to Your System Connector PinoutPower Supply Bus Capacitance LimitationsSoftware Utilities \C\CLIB\SPICA.LIB\C\CLIB\CPICA.LIB \C\CLIB\MPICA.LIBDOS Qbasic Library/Programs \B\SOURCE\I2CINC.BAS\B\SOURCE\PROMREAD.BAS \B\SOURCE\PROMWRIT.BASWindows LIB/DLL Functions Using the Utilities RoutinesInt ownaddress Int sclkInt i2cstatus Int slaveaddressInt setnack Calibre Int i2cdata Calibre Int i2cstatus Number if the adapter is to read from the slave Qbasic Routines Ownaddress%Sclk% I2cstatus%Slaveaddress% Setnack% I2cdata%See Appendix a for details status codes I2cstatus% Is to read from the slave Libraries for Programming in Microsoft Windows Environments Int baseaddressInt statuswait Int ErrCode Int wrDataSendaddress Address to be accessed via the I2C, e.g. A1H Int sendbytesint far *transferarray Int far *transferarrayInt bsent Int getbytesint far *transferarray Int nobytesreadSlave using the adapter Further Information Bit 4 The Bus Error BER Bit Appendix a Parallel I2C Communications Adapter Status CodesBit 7 MSB The Pending Interrupt Not PIN Bit Bit 6 Not UsedAppendix B Parallel I2C Communications Adapter Control Codes Question Get corrupted transfers why is this? Most Commonly Asked I2C QuestionsQuestion Do you have software to talk to my........? QuestionCode. Why? Please Email Your Query to