Calibre UK UCA93 Int ownaddress, Int ClockSpeed, Int BusVoltage, Int PullUpsOn, Int SlaveAddress

Page 10

CALIBRE

3.3.Function Description

3.3.1.

Setup

 

Function specification

int Setup(int OwnAddress, int ClockSpeed, int BusVoltage, int PullUpsOn, int

SlaveBlockTimeout)

 

Parameters are:

int ownaddress

 

 

This is the I2C 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 ownaddress = 57H the card will respond to a

 

 

write address of AEH and a read address of AFH.

 

 

int ClockSpeed

 

 

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

 

 

master. For 400kHz enter 400, for 90kHz enter 90.

 

 

Maximum value 400 minimum value 25

 

 

int BusVoltage

 

 

The desired bus voltage multiplied by 100 e.g. 330 would give a bus voltage

 

 

3.3V. Please note that if a value between 4.2V and 5V is requested the output

 

 

will be 5V.

 

 

Maximum value 500 (5V) Minimum value 180 (1.8V).

 

 

int PullUpsOn

 

 

Set (1) to turn the pull up resistors on, clear (0) to turn them off.

 

 

int SlaveBlockTimeout

 

 

This parameter is only used by the slave block functions. If the Master has not

 

 

completed the transfer in this period (seconds) the Adapter will abort the

 

 

transfer and return an error code.

 

 

Range 1 – 255 seconds. NOTE: setting this value to 0 will prevent the Adapter

 

 

from timing out the slave block function.

Parameters returned

If the software fails to find the driver error code 8000H is returned otherwise the

 

 

status is returned.

Prerequisites

None.

Functional description

This function initialises Adapter ready for I2C transfers.

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

 

Normally there will be another transfer (data read or write) after the

 

SendAddress and so SetNack is enabled (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 by running Setup.

Functional description

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

 

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.

Issue 1.0

Page 7

01/07/03

 

Image 10
Contents Calibre Calibre Contents Packing List Connecting the Adapter to your SystemGeneral Introduction Bus Termination and ProtectionVariable Voltage Bus Power Supply Bus Capacitance Limitations/Cable ChoiceInstalling the Adapter IntroductionLibraries for Programming in Microsoft Windows Environments Function Prototypes Calibre Int ClockSpeed Int SlaveBlockTimeoutInt ownaddress Int BusVoltageInt I2CData Int DataByteSendAddress NoneUsing the Adapter Int I2CstatusInt DataVal Int NoBytesToSendInt NoTries Returns an unused integerInt RdData Int TimeoutInt NoBytesToTransmit Int NoBytesToReceive Int PullupVoltage Int IOState IntSendAddressNoStatus WriteByteNoStatus Real-Time Bus Monitor StopBit 7 MSB The old PIN Bit Bit 4 The BER Bus Error BitAppendix a I2C Communications Adapter Status Codes Bit 5 The old STS BitBlock Functions USB Bus CharacteristicsPolling the Status Register and how to avoid it Block Write FunctionSlave Transmitter Function Slave Receiver FunctionCalibre General Questions When the the Most Commonly Asked I2C QuestionsQuestion Get corrupted transfers why is this? Question Do you have software to talk to my........?