I2C and PCF8574 - ShiftOut

Started by andrewflys September 21, 2002
Hi all,

I had seen some earlier emails saying that folks had successfully
migrated Pete A's i2c routines to use shiftout instead of putpin in
a loop. I substituted it for the existing code and had little
luck...

eg:

Public Sub I2C_WorksFine (ByVal O_byte As Byte)

DIM N as Byte For N = 1 TO 8 Step 1
If (O_byte >= 128) then ' most sig bit is a one
Call I2C_high_sda()
' Call PutB(1) ' used for debugging
Else
Call I2C_low_sda() ' set SDA and then clock
' Call PutB(0) ' used for debugging
End If

Call I2C_high_scl()
Call I2C_low_scl()

O_byte = O_byte * 2 ' shift left

Next
' Call NewLine() ' used for debugging
End Sub

Sub I2C_ShouldWorkButDoesnt (byval I2cData As Byte)
'debug.print CStr(I2cData)
Call ShiftOut(SDA_PIN, SCL_PIN, 8, I2cData) ' shift data
out
Call PutPin(SDA_PIN, bxInputTristate) ' turn SDA around
Call PutPin(SCL_PIN, bxOutputHigh) ' and clock in the
ack' bit
Call PutPin(SCL_PIN, bxOutputLow)
End Sub
Anyone had any luck using shiftout with the Phillips PCF5874 I/O
expander?

Thanks,

Andrew