Can anyone help me with the Basic_I2C_Driver object?
Sabre00
Posts: 30
Can anyone help me with the Basic_I2C_Driver object?
The problem I am having is that when I use it as an object with in another object I am not sure where the data is being stored when read within the Basic_I2C_Driver.
can anyone help me with this problem?
The problem I am having is that when I use it as an object with in another object I am not sure where the data is being stored when read within the Basic_I2C_Driver.
can anyone help me with this problem?
Comments
If you want some examples of using it to read I2C sensors then look at hmc6343 or lis302dl on obex. If you are talking about reading/writing to eeprom, I know the support for this is in the driver but I haven't used it.
I may end up writing my own and posting it on the obex...
I then tried to write to the EEPROM using the following : I2C.WriteByte(16,$A0,$0000,"F") where pin 16 by default pin 17 are the SCL and SDA pins respectively.
I then have a 50 millisecond delay, being very generous. Then I use the following. I2C.ReadByte(16,$A1,$0000).
However the object seems to only return if the action was successful, so assigning that statement to a variable was useless and the variable "@data" where the retrieved byte seems to be stored I can't seem to access from that object.
sorry if that isn't much help. I am not on the same system where I wrote the original code. Any help would be appreciated.
It doesn't exist once ReadByte returns. ReadByte returns a -1 (TRUE) when an error occurs.
On success, it returns the byte that was read.
If you want to detect errors, you need to store the result of ReadByte into a WORD or LONG
variable, test for -1 or TRUE and, if not equal, you can copy the resulting byte to a BYTE variable.
If you don't want to do it this way, you can call ReadPage instead. ReadByte, ReadWord, and
ReadLong are just "wrappers" around ReadPage for convenience. Similarly, WriteByte, WriteWord,
and WriteLong are just "wrappers" around WritePage for convenience.
var
byte·readb
i2c.writebyte(16,$a0,$0000,"F")
readb := i2c.readbyte(16,$a0,$0000)
LCD.WRITEBYTE(4,15,I2C.ReadByte(16,$A0,$0000)).
I am using an LCD to output the data and I created my own object for that. but this line places the readbyte from the EEPROM at line 4 position 15. now that the easy part is over now on to coding the rest.