CALIBRE
4.3.QBASIC Routines
4.3.1.I2C Setup/Initialisation Routines
Function definition: | setup (ownaddress as integer, sclk as integer) | |
Usage | call setup(ownaddress as integer, sclk as integer) | |
Function: | procedure to set up Parallel I2C Communications Adapter. | |
Parameters are: | ownaddress% |
|
| 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% = &h57, the card will respond to a Write | |
| to address &hAF. Be sure not to select an address which is already in use by | |
| any other device in your I2C system. If ownaddress% &h00 the adapter will | |
| monitor all I2C bus information but will not affect any data transfers, thus | |
| acting as a bus monitor. |
|
| sclk% |
|
| the SCL clock rate (bit rate for I2C serial bus). | |
| Value of sclk% | Approximate SCL (KHz) |
| 0 | 90 |
| 1 | 45 |
| 2 | 11 |
| 3 | 1.5 |
Value Returned: | none. |
|
I2C status on exit: | I2C status on exit from routine the Parallel I2C Communications Adapter will | |
| have the serial interface enabled, also data reception acknowledge will be | |
| enabled. The status register will contain 0x81 (assuming that no other | |
| masters exist on the I2C system, if this is not the case then the contents of | |
| the status register will also depend on externally generated bus activity). | |
Example Usage: | (see also sample programs) |
'This will set up the Parallel I2C Communications Adapter with an I2C slave address of &HAE and a SCL clock rate of approximately 45KHz
sub main
ownaddress% = &h57 ' Own slave address set to &h57 (hex)
sclk% = 1 | ' Serial clock rate set to 45KHz |
call setup(ownaddress%, sclk%)
print"Parallel I2C Communications Adapter initialised"
end sub
4.3.2.I2C Status Checking Routine
Function definition: | getstatus%() |
Usage: | I2Cstatus% = getstatus |
Function: | function to read status register of Parallel I2C Communications Adapter. |
Parameters are: | None. |
Value Returned: | i2cstatus% |
| where i2cstatus is an integer from &H00 to &HFF which indicates the current |
| status of the PICA93LV. |
Issue 1.3 | Page 14 |
22/07/99