I2C communication sequence, help please.

Hi

I have a component, a TI Motor driver DRV10983, that specifies the I2C communcation sequence as shown in the attachement to this post.

I wrote this code to match that. Can I expect this to work based on the sequence shown?

byte read_DRV10983_Register(byte reg_addr)
{
  byte data;

  // Set register to read
  Wire.beginTransmission(DRV10983_I2C_ADDRESS);
  Wire.write(reg_addr);
  Wire.endTransmission();

  // Read the register
  Wire.requestFrom(DRV10983_I2C_ADDRESS,1);
  data = Wire.read();
  
  return data;
}

I’m asking because I am getting data, but not the data that I am expecting, so something is wrong somewhere.

Left column is what I expect, right is what I get.

Default Read
0x4A 0x39
0x4E 0x1E
0x2A 0x3A
0x00 0x8
0x98 0x50
0xE4 0xDA
0x7A 0x8B
0xFC 0x10
0x69 0x27
0xB7 0x37
0xAD 0x4
0x0C 0xC

Thanks

Capture.JPG

OP image:Capture.JPG

Left column is what I expect, right is what I get.

Default Read
0x4A 0x39
0x4E 0x1E
0x2A 0x3A
0x00 0x8
0x98 0x50
0xE4 0xDA
0x7A 0x8B
0xFC 0x10
0x69 0x27
0xB7 0x37
0xAD 0x4
0x0C 0xC

What is the value assigned to DRV10983_I2C_ADDRESS?

0x052, as the 7 bit address for the device is 101 0010

But the addresses for write and read are 0xA4 and 0xA5 respectively, which they become when the read/write bit is added by the Wire-lib, as I have understood things.

Is that correctly understood?

Try the following sketch and check that you have got a text message and 0x0C on the Serial Monitor.

#include<Wire.h>

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  //-----------------
  Wire.beginTransmission (0x52);//(DRV10983_I2C_ADDRESS);
  Wire.write (0x2B);//EEPROM location address which contains 0x0C as default value (reg_addr);
  byte busStatus = Wire.endTransmission();
  //--------------------
  if(busStatus !=0)
  {
    Serial.print("I2C Bus Communication Problem...!");
    while(1); //wait for ever
  }
  Serial.println("I2C device is found.");
  //------------------------
  Wire.requestFrom (0x52, 1);//(DRV10983_I2C_ADDRESS, 1);
  byte data = Wire.read();
  //---------------------
  Serial.print(data, HEX);  //Serial Monitor will show: 0x0C
}

void loop()
{
  
}

Hi

The last row of data in the list above is 0x0C, which is address 0x2B as you mention, and that happens to be the one and only piece of data that matches.

I also did check the return value of endTransmission, which was zero.

So it looks like it is working, apart from that all data but one is a mismatch from default values, and it is a brand new IC, so should match. Also, there's a register that returns the supply voltage, 0x1A. My supply voltage is 7.37V, which matches a register value of 0x3F, but it reports 0x47 which indicates 8 volts.

I guess I need to hook up to a variable supply and see what different voltages reports.

I know tried writing to one of the writeable registers and read back, and the written data came back ok. So I guess the default values are all fck'ed up for some reason.

I think I will ignore this discrepancy and get started doing a full setup, and see where that takes me. I'll just assume this is working as it should. Most things points towards that anyway.

It is a little bit annoying having to wait 5 minutes between posts, any chance of having this fixed? :wink:

That device operates at 3.3V for the i2c. The maximum voltage in the datasheet says 4V. Which arduino are you using?

Thanks for pointing that out, that completely slipped my mind even though I know it :wink:
I was running an Uno, but swapped to the Due. Luckily no harm done. Samme issue though. But I ignored it. Clearly the chip did not come with its default values. Thanks TI…

Anyway, after a lot of mess the little brushless motor is now starting up, running, and stopping fine. Just need to do some fine tuning to get max speed, stability etc out of it. But that’ll be tomorrow. Almost morning here in Sweden now, so, time to hit the sack.

Thanks for all the input!

Thomasx:
I think I will ignore this discrepancy and get started doing a full setup, and see where that takes me. I'll just assume this is working as it should. Most things points towards that anyway.

That is the Engineering attitude/approach; but take care of personal safety, equipment safety and calculated risk.