27220 Parallax Inc, 27220 Datasheet - Page 202

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
' Do a block read from clock registers
Get_Clock:
' =====[ 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
GOSUB I2C_Stop
RETURN
GOSUB I2C_Start
i2cWork = slvAddr & %11111110
GOSUB I2C_TX_Byte
IF (i2cAck = Nak) THEN Get_Clock
i2cWork = 0
GOSUB I2C_TX_Byte
GOSUB I2C_Start
i2cWork = slvAddr | %00000001
GOSUB I2C_TX_Byte
FOR idx = 0 TO 6
NEXT
GOSUB I2C_RX_Byte_Nak
control = i2cWork
GOSUB I2C_Stop
RETURN
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
i2cWork = secs(idx)
GOSUB I2C_TX_Byte
GOSUB I2C_RX_Byte
secs(idx) = i2cWork
IF (addrLen = 2) THEN
ENDIF
i2cWork = wrdAddr.BYTE0
GOSUB I2C_TX_Byte
i2cWork = wrdAddr.BYTE1
GOSUB I2C_TX_Byte
' send Start
' send slave ID (write)
' wait until not busy
' point at secs register
' send slave ID (read)
' read secs to year
' read control
' send Start
' send slave ID (write)
' wait until not busy
' send word address (1)
' send word address (0)
' send data

Related parts for 27220