Calibre UK UCA93 manual Slave Transmitter Function, Slave Receiver Function

Page 23

CALIBRE

The slave functions of the UCA93 differ most from traditional Calibre AT and PCI bus based products. A user must make a pre-determined decision whether to put the adapter into master, slave transmitter or slave receiver modes. The adapter’s own address is established as part of the Setup function. If the adapter is in master mode (the default) , it will not respond to its own address if this is generated by another master on the system. If the adapter is in either slave mode it will recognise its own address and an acknowledge will be generated on the I2C bus.

Slave Transmitter Function

When the BlockSlaveTransmittter function is called the user sends a data block of selectable size (max 2048bytes) into a buffer together a timeout time in seconds. When a master generates the adapter’s own address (either write or read) the adapter will generate an acknowledge on the I2C bus.

If the address was even (master write) the adapter will assume that the master wishes to send a pointer to a location in the data block. The pointer can be one or two bytes. If the pointer is single the upper byte will default to 0x00. If the master fails to send a pointer both bytes will default to 0x00 and if the master send more than two bytes on the last two will be used – the others will be discarded. Data in the block will then be discarded so that the first byte aligns with the pointer sent. Note that the adapter will hold SCL low during this alignment which slows down the I2C bus – the master should be able to tolerate this.

If the address was odd (master read) the adapter will assume that the master does not wish to send a pointer and that data transmission should start from the beginning of the data block.

If the master has sent a pointer the master should then generate a restart followed by the adapter’s read address which will be acknowledged.

Data is then transmitted from the adapter to the master starting at the pointer location. Remembering that the master is in charge of the length of the transfer and the generation of the stop, the adapter will transmit data to the master for as long as required. If the transfer is longer than the available data the last available byte in the block will be repeated; if it is shorter then not all the data in the block will be used.

When the transmission is terminated by the master the adapter will send a single byte back to the host.

The BlockSlaveTransmitterStatus function waits for this byte and the byte is interpreted as described the function definition. Note that this byte may return either as a result of a timeout (when the master fails to initiate a transfer to the adapter within the timeout seconds) or the master correctly terminating the transfer.

When the BlockSlaveTransmittter function terminates the adapter goes back into an idle state – it will not acknowledge its own address or repeat any other slave behaviour until the slave function is called again.

Users will note that the BlockSlaveTransmittter function is designed as much as possible to emulate the behaviour of an EEPROM. The only differences are that the block size is limited to 2048 byte, there may be some delay on the bus white data is aligned with the pointer and the function only runs once without being recalled. The function is also designed to keep the transmission going even if a mistake is made in the master’s protocol although it is important that the master generates a stop eventually.

Slave Receiver Function

The BlockSlaveReceiver function is simpler than the previous function! When it is called the user must instruct the adapter on how many bytes it wishes to receive back (max 2048) and on a timeout in seconds.

When the master generates the adapter’s own address the adapter will generate an acknowledge on the I2C bus. Since the adapter is about to receive data this should be an even (write) address.

The master then transmits data to the adapter and the adapter will acknowledge each byte then put it into the pre-determined size buffer to be transmitted to the host. The adapter will accept data from the master for as long as the master sustains the transfer. If too much data is sent by the master, the adapter keeps on acknowledging the master but stops putting data into the buffer. Likewise, if the master terminates the transfer before the buffer is full, the adapter pads out the buffer with 0xFFs to the predetermined size.

Issue 1.0

Page 20

01/07/03

 

Image 23
Contents Calibre Calibre Contents Bus Termination and Protection Connecting the Adapter to your SystemGeneral Introduction Packing ListBus Capacitance Limitations/Cable Choice Variable Voltage Bus Power SupplyIntroduction Installing the AdapterLibraries for Programming in Microsoft Windows Environments Function Prototypes Calibre Int BusVoltage Int SlaveBlockTimeoutInt ownaddress Int ClockSpeedNone Int DataByteSendAddress Int I2CDataInt I2Cstatus Using the AdapterReturns an unused integer Int NoBytesToSendInt NoTries Int DataValInt NoBytesToTransmit Int TimeoutInt RdData Int NoBytesToReceive Int PullupVoltage Int Int IOStateSendAddressNoStatus WriteByteNoStatus Stop Real-Time Bus MonitorBit 5 The old STS Bit Bit 4 The BER Bus Error BitAppendix a I2C Communications Adapter Status Codes Bit 7 MSB The old PIN BitBlock Write Function USB Bus CharacteristicsPolling the Status Register and how to avoid it Block FunctionsSlave Receiver Function Slave Transmitter FunctionCalibre Question Do you have software to talk to my........? When the the Most Commonly Asked I2C QuestionsQuestion Get corrupted transfers why is this? General Questions