I2C not working for me..see if you can help?
doughboy
Posts: 12
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 --
Post Edit -- An AD7745 has a 24-bit (which is a little more than a Byte) output.
Post Edited (PJ Allen) : 6/14/2008 12:55:50 AM GMT