Revision 1.7 Page 14 of 27
09/12/1999
Function: procedure to send a Stop (end of communication signal) down the I2C Bus,
ending a transmission or reception with a slave that was address previously by
sendaddress.
Parameters are:
controladdress% The address of the I2C Communications Adapter control register, equal to
1+(base address set by links on circuit board).
Value Returned:none.
I2C status on exit from routine:
The status of the I2C/ the Communications Adapter will be &h81 - bus idle and no
unread/untransmitted data in the data register. Note - this may not be the case in
a system where there is another master as well as the 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).
Example Usage: (see also sample programs)
$include “i2c.inc” ‘* This contains the I2C routines*
baseaddr% = &h310 ‘* Adapter’s base address = 310 (hex) *
controladdress% = baseaddr% + 1 ‘* Control Register address *
call sendstop(controladdress%)
print”Stop has been transmitted”
‘* This will write a stop to the I2C Bus*
5.2.7. I2C Restart and Address Sending Routine
Name: restart(baseaddr%, slv% setnack%)
Usage: call restart(baseaddr%, slv%, setnack%)
Function: procedure to send a Restart and the slave address of device that is to be
communicated with, without a Stop having been sent at the end of the last
transmission/reception. This routine is particularly useful for reading memories
which must first have a data pointer written to them to select where the read is to
occur from, and must then have their read address sent with a Restart to
proceed with the read operation.
Parameters are:
baseaddr% the base address of the I2C Communications Adapter set by links on circuit
board.
slv% the slave address of the device which is to be communicated with. This will be an
even number if the communicated with. This will be an even number if the
adapter is to write to the slave, add 1 to get an odd number if the adapter is to
read from the slave.
setnack% this controls whether the 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 set = 0.
Value Returned:none.
I2C status on exit from routine:
The status of the I2C/ the Communications Adapter will be either &h00 - bus the
busy and unread data in the data register or &h80 - bus busy and no unread data
in the data register when a Restart and Salve Address have been successfully
transmitted (see Appendix A for details of Status Codes).
Example Usage:
$include “i2c.inc” ‘* This contains the I2C routines*
baseaddr% = &h310 ‘* Adapter’s base address = 310 (hex) *