Calibre UK PICA93LV user manual Appendix B Parallel I2C Communications Adapter Control Codes

Page 32

CALIBRE

￿

￿

APPENDIX B Parallel I2C Communications Adapter Control Codes

The Control Register should normally be written using the setup, sendaddress and sendstop routines. To implement more advanced functions for example, enabling hardware interrupt generation these routines may need to be modified or the users own routines used in their place.

The Control Register is accessed using the controloutp() and controlinp() functions. The function definitions for these are as follows:

void controloutp(int controldata); int controlinp(void);

The Data Register is accessed using the dataoutp() and datainp() functions. The function definitions for these are as follows:

void dataoutp(int controldata); int datainp(void);

E.g. in C, controloutp(0xc3); would cause an Parallel I2C Communications Adapter to generate a Stop condition on the I2C bus. For detailed information on these codes, the Philips data sheet on the PCF8584 device (see Further Information section).

0x00 read/write own address register (followed by a data byte to the data register).

0x20 read/write clock register (followed by a data byte to the data register).

After either of the above operations, 0x41 must be written to the control register to re-enable the I2C interface.

0xC3 send a Stop signal over the I2C bus.

0x41 I2C NOP (no operation) instruction, acknowledge enabled. (Use 0x41 and 0x40 to turn on and off acknowledge)

0x45 (While bus is free) - Send Start & slave address, acknowledge enabled. The address to be sent must have first been written to the data register before sending the start code.

0x45 (While already master on the bus) - Send Repeated Start & slave address (Restart). The address to be sent is placed in the data register after sending the start code.

0x47 Send Stop, Start, slave address (i.e. restart transmission without releasing control of the I2C bus). The address to be sent is placed in the data register after sending the start code.

To execute the last four instructions with acknowledge disabled, i.e. negative acknowledge - nack, send the control code - 1, e.g. 0x40, 0x44, 0x46.

Issue 1.3

Page 29

22/07/99

Image 32
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 setnack Int i2cstatusInt slaveaddress 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 Int statuswait Libraries for Programming in Microsoft Windows EnvironmentsInt baseaddress Int ErrCode Int wrDataSendaddress Address to be accessed via the I2C, e.g. A1H Int bsent Int sendbytesint far *transferarrayInt far *transferarray 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