PDA

View Full Version : I2C Questions



n0yox
- 13th May 2014, 00:59
I am working with the RDA1846, the data sheets says the 7 bit control address is 1110001 plus a read/write bit does I2CWRITE add this read/write bit in the proper place or do I need add it to the control address? It also says it should be sent MSB first is this how I2CWRITE handles this control byte? I am very confused !

ADDRESS VAR BYTE
DATAH VAR BYTE
DATAL VAR BYTE
I2CWRITE DATAIO,CLOCK,%1110001,ADDRESS,[DATAH,DATAL]

Thanks You!
https://dallasmakerspace.org/w/image...ing_manual.pdf "Page 5"

Charlie
- 13th May 2014, 02:17
Add the bit to the control address (1110001x) to make a complete byte, where x = 0 or 1 depending on read or write. MSB first is standard so nothing to do.
Instead of DATAH and DATAL as bytes, use DATA VAR WORD.

sort of:
DATAIO VAR PORTA.0
CLOCK VAR PORTA.1
CMD_WRITE CON %11100010
CMD_READ CON %11100011
DATA VAR WORD

I2CWRITE DATAIO, CLOCK, CMD_WRITE, [DATA]

n0yox
- 14th May 2014, 00:10
Thank You, I continue to have problems and have been reading data sheets, I do not understand this statement in the datasheet "The 7-bit chip address is 7’b0101110 when SEN is high, or is 7’1110001 when SEN is low." the SEN should not have anything to do with the I2C interface The notation of "7’1110001 and 7’b0101110" means nothing to me at this point.

Thanks for any input!!

Roger


Add the bit to the control address (1110001x) to make a complete byte, where x = 0 or 1 depending on read or write. MSB first is standard so nothing to do.
Instead of DATAH and DATAL as bytes, use DATA VAR WORD.

sort of:
DATAIO VAR PORTA.0
CLOCK VAR PORTA.1
CMD_WRITE CON %11100010
CMD_READ CON %11100011
DATA VAR WORD

I2CWRITE DATAIO, CLOCK, CMD_WRITE, [DATA]

Charlie
- 14th May 2014, 13:25
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?

n0yox
- 15th May 2014, 05:23
Thank You!

Do you think it should be

"I2CWRITE DATAIO, CLOCK, CMD_WRITE, [REGISTER,DATA_H,DATA_L] or
I2CWRITE DATAIO, CLOCK, CMD_WRITE, REGISTER,[DATA_H,DATA_L]". I will try your code in the morning at let you know what I find. I am just about to the point of giving up so your input is very much appreciated!I believe my hardware is right however it may be a good idea to do another check? I see 11100011 in my sleep now:)

Thank You,

Roger



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?