I2C problem reading registers: Hall effect sensor TLE493D-A2B6

Status
Not open for further replies.

shirriff

Member
I'm trying to read a register over I2C using the i2c_t3 on a Teensy 3.6, but I don't get any data. I think the problem is that the Wire library does a register read by a write of the register address followed by a read of the data, but the datasheet shows a slightly different protocol where the sensor address and register address are sent as a read (not a write) followed by the read data, all as one frame.

Is there a way to get the Wire library to do a register read in this way? Is this a normal way of reading a register or is this chip using an unusual I2C variant? I can try bit-banging the frame format that appears in the datasheet, but I figured I should ask first in case I'm off in the weeds.

Here's the code I'm using:
Code:
  Wire.beginTransmission(0x35);
  Wire.write(3);
  Wire.endTransmission();
  Wire.requestFrom(target, (size_t)1);
  Serial.printf("%x\n", Wire.read());

I looked with an oscilloscope and the signals are good, and the sensor replies to the requests with an ACK but doesn't provide any data for the read. So it looks like a protocol problem, not an electrical problem.
 
This seems to use what is known as 10-bit addressing ("2-byte read" in the manual). I don't think any of the standard Arduino or Teensy libs support that!

However the sensor can be reconfigured to use normal 8-bit addressing ("1-byte read"), by following the procedure described in §2.1.3.2 of the user manual.
 
Thanks Paul and damiend! I switched to 1-byte reads and then I can read the registers. I'll try the Infineon library if I need more performance.

For reference, the code to switch to 1-byte reads is:
Code:
  Wire.beginTransmission(0x35);
  Wire.write(0x11); // mode register
  Wire.write(0x10); // PR bit
  Wire.endTransmission();

Then I can read all the registers with
Code:
  Wire.beginTransmission(0x35);
  Wire.requestFrom(target, (size_t)0x17);
  for (int i = 0; i < 0x17; i++) {
    buf[i] = Wire.read();
  }
 
Status
Not open for further replies.
Back
Top