27220 Parallax Inc, 27220 Datasheet - Page 191

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
' =====[ High Level I2C Subroutines]=======================================
' Random location write
' -- pass device slave address in "slvAddr"
' -- pass bytes in word address (0, 1 or 2) in "addrLen"
' -- word address to write passed in "wrdAddr"
' -- data byte to be written is passed in "i2cData"
Write_Byte:
NEXT
IF (fails = 0) THEN
ENDIF
END
GOSUB I2C_Start
i2cWork = slvAddr & %11111110
GOSUB I2C_TX_Byte
IF (i2cAck = Nak) THEN Write_Byte
IF (addrLen > 0) THEN
ENDIF
i2cWork = i2cData
GOSUB I2C_TX_Byte
GOSUB I2C_Stop
RETURN
FOR test = 0 TO 3
NEXT
DEBUG CRSRXY, 11, 6, "None. All locations test good."
IF (addrLen = 2) THEN
ENDIF
i2cWork = wrdAddr.BYTE0
GOSUB I2C_TX_Byte
LOOKUP test, [$FF, $AA, $55, $00], outVal
DEBUG CRSRXY, 11, 3, IHEX2 outVal
i2cData = outVal
GOSUB Write_Byte
PAUSE 10
GOSUB Read_Byte
inVal = i2cData
DEBUG CRSRXY, 11, 4, IHEX2 inVal,
IF (inVal = outVal) THEN
ELSE
ENDIF
PAUSE 10
i2cWork = wrdAddr.BYTE1
GOSUB I2C_TX_Byte
DEBUG "Pass "
fails = fails + 1
DEBUG "Fail ", CRSRXY, 11, 6, DEC fails
EXIT
CRSRXY, 11, 5
' use four patterns
' terminate location
' send Start
' send slave ID (write)
' wait until not busy
' send word address (1)
' send word address (0)
' send data

Related parts for 27220