CALIBRE
Appendix B Migration Notes for Existing Calibre I2C Customers
These notes are intended for customers who have code working on one or more of Calibre UK’s existing AT or PCI based adapters and wish to convert it to work with the new UCA93 Adapter. The fundamental differences are a much reduced reliance on polling the status register, a new way of calling slave functions and the introduction of new block transfer functions.
USB Bus Characteristics
The USB V1.1 bus is fast – data transfer rates can approach a 1 million
Polling the Status Register (and how to avoid it)
Traditional Calibre software requests a function (say SendAddress) then polls the status register until the status indicates that the function has completed. On the UCA93 this is replaced by a function of the type
I2CStatus = SendAddress(SlaveAddress);
which instructs the adapter to generate the start transmit the address then waits for a single status byte to be returned from the adapter indicating how the transfer went. See Appendix A for details. One status byte will always be returned even if the function fails and times out (about 500uS). Multiple polls are not needed nor desirable and should be removed from code.
Previous Calibre I2C products used the PIN bit to synchronise data transfers between the I2C bus and the host PC but this now is all handled by the PIC16F874 microcontroller on the Adapter. Communication between the Adapter and host is now synchronised differently so to all intents and purposes this bit is now redundant.
Block Functions
Block functions are I2C master functions designed to take advantage of the high bandwidth of the USB bus whilst minimising data direction changes which slow the bus down. Instead of piecing together I2C functions the user can for example load data into an array, then call a BlockWrite function.
Block Write Function
On receiving the BlockWrite function the adapter will generate the start and address, then optionally a single or double pointer followed by a block of data up to 2048 bytes which is preset by the SetBlockData function. If the slave device does not acknowledge, the adapter will send a stop after the address, then repeat the sequence again up to Tries times to rouse the slave. If the slave still does not acknowledge, the function will terminate cleanly. The user should keep track of the BlockWrite function by immediately calling the BlockWriteStatus function which will return the status byte indicating how the BlockWrite function got on and how it terminated.
Block Read Function
On receiving the BlockRead function the adapter will generate the start and address, then optionally a single or double pointer. If the slave device does not acknowledge, the adapter will send a stop after the address, then repeat the sequence again up to Tries times to rouse the slave. If the slave still does not acknowledge, the function will terminate cleanly. The user should keep track of the BlockRead function by immediately calling the BlockReadStatus function which will return the status byte indicating how the BlockRead function got on and how it terminated. The data returned from the slave to the host via the adapter can be accessed by calling the BlockRead function which accesses a global variable.
Slave Functions |
|
Issue 1.0 | Page 19 |
01/07/03 |
|