First you say your I2C address is correct since you see ACK on the scope, good. But it does not write all data apparently, however do you see ACKs after each data byte on the scope? The most logical reason it does not send everything is because it does not get an ACK back (which would be weird, if the address is correct).
Then you have several times i2c.stop() commands, that is not needed, the i2c.write/read commands will send a stop command in the end (unless you add ",true" at the end of the command, then it will transmit a restart instead).
In your read function you first write three bytes, however only one is initialized, the other two are randomly what used to be in that register address. The next read it is better to just use the 'normal' read command: i2c.read(RAMaddr, [pointer to wherever you want to store results], [number of bytes to read]); How you used the i2c read command isn't valid, and will for sure not give you what you will expect.
Hopefully that will get you further.
Hi,
I'm having some problems writing to and reading from a RAM in an I2C device.
My code is as follows:
When I look at the I2C with a scope, I see the write data is F08F - when I would expect to see F08F624A. I know the I2C address is correct otherwise I would not get an acknowledge back from the device. During the read stage I see F01F62 on the scope trace! But val in the above comes out as value of cmdw[1] x 2 (in this case c4 hex = 196 dec).
Are my write and/or read routines at fault? The device in question is a ZSC31050 sensor conditioner from ZMD.
I've looked through the forum post which have helped me get this far. Any pointers to help me make progress would be most useful. Thanks in advance.
Chris