Calibre UK PICA93LV user manual Using the Utilities, Routines, Int ownaddress, Int sclk

Page 10

CALIBRE

￿

￿

USING THE UTILITIES

4.1.Introduction

Each utility is documented in a standard format which lists its name, usage, function and effect on the adapter is given. The adapter should be setup prior to any data transfer.

4.2.C Routines

4.2.1.I2C Setup / Initialisation Routine

Function definition:

void setup(int ownaddress, int sclk)

Usage:

setup(ownaddress, sclk);

Function:

procedure to set up Parallel I2C Communications Adapter.

Parameters are:

int ownaddress

 

 

The address to which the adapter is to respond in slave mode. This forms the

 

upper 7 bits of the 8 bit address, the lowest bit being the Read(1) or Write(0)

 

bit. This means that if own = 0x57, the card will respond to a Write to address

 

0xAE and a Read to address 0xAF. Be sure not to select an address which is

 

already in use by any other device in your I2C system.

 

int sclk

 

 

The SCL clock rate (bit rate for I2C serial bus).

 

Value of sclk

Approximate SCL (KHz)

 

0

90

 

1

45

 

2

11

 

3

1.5

Value Returned:

none.

 

I2C status on exit:

I2C status on exit from routine the Parallel I2C Communications Adapter will

 

have the serial interface enabled, also data reception acknowledge will be

enabled. The status register will contain 0x81 (assuming that no other masters exist on the I2C system, if this is not the case then the contents of the status register will also depend on externally generated bus activity).

Example Usage: (see also sample programs) main()

{

int ownaddress, sclk;

 

ownaddress = 0x57;

/* Own slave address set to 0x57 (hex) */

sclk = 1;

/* Serial clock rate set to 45KHz */

setup(ownaddress, sclk);

printf("Parallel I2C Communications Adapter initialised\n");

}

/* This will set up the Parallel I2C Communications Adapter with */

/*an I2C slave address of 0xAE and a SCL clock rate of approximately 45KHz */

Issue 1.3

Page 7

22/07/99

Image 10
Contents Calibre Calibre CopyrightContents General Introduction Configuring the AdapterIntroduction Packing ListInstalling the Adapter Typical PC ConnectionPower Supply Connecting the Adapter to Your SystemConnector Pinout Bus Capacitance Limitations\C\CLIB\CPICA.LIB Software Utilities\C\CLIB\SPICA.LIB \C\CLIB\MPICA.LIB\B\SOURCE\PROMREAD.BAS DOS Qbasic Library/Programs\B\SOURCE\I2CINC.BAS \B\SOURCE\PROMWRIT.BASWindows LIB/DLL Functions Int ownaddress Using the UtilitiesRoutines Int sclkInt slaveaddress Int i2cstatusInt setnack Calibre Int i2cdata Calibre Int i2cstatus Number if the adapter is to read from the slave Sclk% Qbasic RoutinesOwnaddress% I2cstatus%Slaveaddress% Setnack% I2cdata%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 ErrCode Int wrDataSendaddress Address to be accessed via the I2C, e.g. A1H Int far *transferarray Int sendbytesint far *transferarrayInt bsent Int getbytesint far *transferarray Int nobytesreadSlave using the adapter Further Information Bit 7 MSB The Pending Interrupt Not PIN Bit Bit 4 The Bus Error BER BitAppendix a Parallel I2C Communications Adapter Status Codes Bit 6 Not UsedAppendix B Parallel I2C Communications Adapter Control Codes Question Do you have software to talk to my........? Question Get corrupted transfers why is this?Most Commonly Asked I2C Questions QuestionCode. Why? Please Email Your Query to