Calibre UK PICA93LV user manual I2cstatus%

Page 21

CALIBRE

￿

￿

Example Usage:

(see also sample programs)

'This will write a byte of data to a slave previously addressed by sendaddress. */ Sub main

i2cdata$ = &H69 ' Data byte which is to be transmitted */ i2cstatus$ = writebyte (i2cdata$)

if (i2cstatus and &H8000) = &H8000 then

print "Data has not been transmitted status is " + HEX$( i2cstatus%)

else

print "Data has been transmitted"

End If

End Sub

4.3.6.Send an I2C Stop Routine

Function definition:

sendstop%()

Usage:

i2cstatus% = sendstop

Function:

procedure to send a Stop (end of communication signal) down the I2C Bus,

 

sending a transmission or reception with a slave which was address

 

previously by sendaddress.

Parameters are: Value Returned:

I2C status on exit:

Example Usage:

None.

i2cstatus%.

The value returned depends on whether the bus became free. If the bus became free then the status (&H81) is returned.

If the bus does not became free then the last status read IORed with &H8000 will be returned.

The function will read the status a number of times, waiting for the bus to become free, before returning an none free status - this number is defined by the MAXNUMBEROFGOES constant defined in I2CINC.BAS, this value may be altered to suit your system.

The status of the Parallel I2C Communications Adapter will be &H81 - bus idle and no unread / untransmitted data in data register.

Note - this may not be the case in a system where there is another master as well as the Parallel I2C Communications Adapter, since this other master may well have taken control of the bus by the time a program next uses getstatus to read the status register.

(See Appendix A for details of status codes). (see also sample programs)

'This will write a Stop to the I2C Bus sub main

i2cstatus = sendstop

print "Stop has been transmitted status is " + HEX$( i2cstatus%)

end sub

Issue 1.3

Page 18

22/07/99

Image 21
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 i2cstatus Int slaveaddressInt 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 Libraries for Programming in Microsoft Windows Environments Int baseaddressInt statuswait Int wrData Int ErrCodeSendaddress Address to be accessed via the I2C, e.g. A1H Int sendbytesint far *transferarray Int 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