Go Down

Topic: Weird I2c standards? (Read 176 times) previous topic - next topic

swagguy8

Hey guys, I need to control a module (kc32b) with I2c, according to its datasheet, I am unfamiliar with the methods.

Code: [Select]

  Wire.beginTransmission(kc32b_addy);
  Wire.write(0x04); //digitinfo
  Wire.endTransmission();
  Wire.requestFrom(kc32b_addy, 1);



Please review my attachments for documentation, but from what I can understand, first I gotta send the device address (0xcc for kc32b module) the internal address (0x04), then I have to request the 1 byte to get a response (say 0x08 for DTS digital).

Can someone verify that my understanding is correct?


thanks in advance for your help.

Koepel

Correct.

If that schematic had to do with the KC32B module, then it has a 3.3V I2C bus. In that case, use a 3.3V Arduino board or a I2C level shifter.

Find the address with a I2C Scanner. Use the address that is found. If nothing is found, you should fix the I2C bus first.

Code: [Select]

const int kc32b_addy = 0xCC;

Wire.beginTransmission(kc32b_addy);
Wire.write(0x04); //digitinfo
Wire.endTransmission();

Wire.requestFrom(kc32b_addy, 1);
int data = Wire.read();
Serial.println( data, HEX);


Google Translate is able to translate a link to a pdf file.

swagguy8

Correct.

If that schematic had to do with the KC32B module, then it has a 3.3V I2C bus. In that case, use a 3.3V Arduino board or a I2C level shifter.

Find the address with a I2C Scanner. Use the address that is found. If nothing is found, you should fix the I2C bus first.

Code: [Select]

const int kc32b_addy = 0xCC;

Wire.beginTransmission(kc32b_addy);
Wire.write(0x04); //digitinfo
Wire.endTransmission();

Wire.requestFrom(kc32b_addy, 1);
int data = Wire.read();
Serial.println( data, HEX);


Google Translate is able to translate a link to a pdf file.
Oh wait, I missed a bit in the datasheet where it says:

Quote from: From the datasheet
The user host writes the I2C address of the KC32B to 0xcc, which is 11001100, and the read I2C address is 0xcd, which is 11001101.
Perhaps I have to request from the read address:

Code: [Select]

const int kc32b_addy = 0xCC;
const int kc32b_read_addy = 0xcd;

Wire.beginTransmission(kc32b_addy);
Wire.write(0x04); //digitinfo
Wire.endTransmission();

Wire.requestFrom(kc32b_read_addy, 1);
int data = Wire.read();
Serial.println( data, HEX);


Where did you find that schematic you mentioned? The datasheet's only schematic is one of ce2826 which is a dac. It also didn't seem to say anything about whether if the I2c was 3.3 or 5v. I might have to contact their support via wechat to find out.



Koepel

Find the address with a I2C Scanner. Use the address that is found. If nothing is found, you should fix the I2C bus first.

You should use the I2C address that the I2C Scanner finds, instead of guessing what it will be. I think it is 0x66. Arduino uses the 7-bits shifted I2C address. It has the same I2C address for reading and writing.

The schematic that I mentioned is indeed the one in the datasheet for the ce2826. I did not understand why that is in the datasheet. The translated datasheet does not say if that is a 3.3V or 5V I2C bus.
Perhaps the I2C bus connects to the large Cirrus Logic CS495313 chip. That is also a 3.3V chip.

GolamMostafa

#4
Aug 12, 2018, 10:04 am Last Edit: Aug 13, 2018, 06:32 am by GolamMostafa
@swagguy8

We need to review a little bit of the I2C address with the help of the following figure:

Figure-1: I2C Bus Address and R-W/ Bit

1.  In Arduino Platform, the I2C Bus address is always 7-bit (Fig-1). R-W/ (Data Direction Bit) bit is added at the end of the I2C Bus address to form an 8-bit value what is known as Control Byte (Fig-1).

2. When the Master executes Wire.write() command, 0 is added at the end of the I2C Bus address. 1 is added at the end of the I2C Bus address when the Master executes the Wire.requestFrom() command.

Now, let us decode the value 0xCC (11001100) and 0xCD (11001101) that you have mentioned. These values are 8-bit, and they are seen to contain the R-W/ bit when they are decoded in the light of Fig-1. Let us strip out the R-W/ bits (the last bit: 0 and 1)) from the given numbers; the standard 7-bit I2C address for the device comes out as: 0b1100110 = 0x66.

Therefore the appropriate I2C Bus commands would be:
Code: [Select]

  #define kc32b_addy 0b1100110    //0x66

  Wire.beginTransmission(kc32b_addy);
  Wire.write(0x04); //digitinfo
  Wire.endTransmission();
 
  Wire.requestFrom(kc32b_addy, 1);
  byte x = Wire.read();           //x hold 1-byte (8-bit) from internal register with address 0x04.



Go Up