
Originally Posted by
Charlie
I have not used this device, but I had a quick look at the datasheets for you. First, MODE pin should be tied low to put it in I2C mode. When in I2C mode, the SEN (or perhaps SENB) chooses the chip address. I found 2 documents, one calls the pin SEN, the other SENB. "The 7-bit chip address is 7’b0101110 when SEN is high, or is 7’1110001 when SEN is low." So for the example above, tie the SEN(B) pin low. Also you need the address of the register you want to write to, and the two bytes you want to actually write. So to modify what I wrote before:
DATAIO VAR PORTA.0
CLOCK VAR PORTA.1
CMD_WRITE CON %11100010
CMD_READ CON %11100011
REGISTER VAR BYTE
DATA_H VAR BYTE
DATA_L VAR BYTE
I2CWRITE DATAIO, CLOCK, CMD_WRITE, [REGISTER,DATA_H,DATA_L]
When you wish to read, you would first write to set the chip to the right register so you would need to:
I2CWRITE DATAIO, CLOCK, CMD_WRITE, [REGISTER]
I2CREAD DATAIO, CLOCK,CMD_READ,[DATA_H,DATA_L]
Clear as mud?
Bookmarks