I2C not working for me..see if you can help?
trying to do a simple write read to a register code below----
'Pins
'
SDA PIN 0 ' P0 Serial bidirectional data line on the AD7745 [noparse][[/noparse]MUST BE PIN 0 OR 8]
SCL PIN 1 ' P1 Serial clock line on the AD7745
RDY PIN 2 ' P2 RDY pin on the AD7745 goes low when new data is ready
regdata VAR Byte
regdata = $00
INPUT SDA
INPUT SCL
LOW SDA
INPUT RDY
I2COUT SDA,$90,$0A,[noparse][[/noparse]$FF]
I2CIN SDA,$91,$0A, [noparse][[/noparse]STR regdata \8]
DEBUG BIN8 regdata,CR
the debug never gives me what I am writing to the register....SDA and SCLk are pulled up high......any help would be great!
btw the device works that im trying to talk to as it has usb as well
'Pins
'
SDA PIN 0 ' P0 Serial bidirectional data line on the AD7745 [noparse][[/noparse]MUST BE PIN 0 OR 8]
SCL PIN 1 ' P1 Serial clock line on the AD7745
RDY PIN 2 ' P2 RDY pin on the AD7745 goes low when new data is ready
regdata VAR Byte
regdata = $00
INPUT SDA
INPUT SCL
LOW SDA
INPUT RDY
I2COUT SDA,$90,$0A,[noparse][[/noparse]$FF]
I2CIN SDA,$91,$0A, [noparse][[/noparse]STR regdata \8]
DEBUG BIN8 regdata,CR
the debug never gives me what I am writing to the register....SDA and SCLk are pulled up high......any help would be great!
btw the device works that im trying to talk to as it has usb as well

Comments
The register you're writing to is the configuration register. Is this what you want?
I2COUT's Pin argument is 0 or 1 and that determines which set of pins to use for SDA and SCL already (P0 & P1 or P8 & P9, respectively.)·
So, the SDA and SCL pin declarations are unnecessary.
SDA PIN 0··X ' P0 Serial bidirectional data line on the AD7745
SCL PIN 1··X··' P1 Serial clock line on the AD7745
I/O direction for SDA·is handled automatically,·given the context (I2CIN or I2COUT).
So, the INPUT commands are unnecessary.
INPUT SDA· X
INPUT SCL· X
LOW SDA· · X
I don't know what you're using LOW SDA for.
I2COUT SDA,$90,$0A,[noparse][[/noparse]$FF]
I2CIN SDA,$91,$0A, [noparse][[/noparse]STR regdata \8]
You "could" do that if you had declared SDA as a VARiable or CONstant
These two examples tokenize --
' {$STAMP BS2p} ' {$PBASIC 2.5} regdata VAR Byte regdata = $00 RDY PIN 2 ' P2 RDY pin Start: I2COUT 0,$90,$0A,[noparse][[/noparse]$FF] I2CIN 0,$91,$0A, [noparse][[/noparse]regdata] DEBUG BIN8 regdata,CR PAUSE 1000 GOTO Start ' {$STAMP BS2p} ' {$PBASIC 2.5} regdata VAR Byte regdata = $00 RDY PIN 2 ' P2 RDY pin Start: I2COUT 0,$90,$0A,[noparse][[/noparse]$FF] IF RDY = 0 THEN I2CIN 0,$91,$0A, [noparse][[/noparse]regdata] DEBUG BIN8 regdata,CR PAUSE 1000 GOTO StartPost Edit -- An AD7745 has a 24-bit (which is a little more than a Byte) output.
' {$STAMP BS2p} ' {$PBASIC 2.5} regdata VAR Byte (3) ' ************* regdata = $00 RDY PIN 2 ' P2 RDY pin Start: I2COUT 0,$90,$0A,[noparse][[/noparse]$FF] I2CIN 0,$91,$0A, [noparse][[/noparse]STR regdata\3] ' ************* DEBUG BIN8 regdata (0),CR DEBUG BIN8 regdata (1),CR DEBUG BIN8 regdata (2),CR PAUSE 1000 GOTO StartPost Edited (PJ Allen) : 6/14/2008 12:55:50 AM GMT