Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues reading register contents from the IC #2

Open
nitin710 opened this issue Nov 22, 2024 · 1 comment
Open

Issues reading register contents from the IC #2

nitin710 opened this issue Nov 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nitin710
Copy link
Contributor

nitin710 commented Nov 22, 2024

The I2C protocol for reading registers from the KTD2026 (datasheet) seems to be different from the usual implementation.
<SEND ADDRESS IN READ MODE> <REGISTER TO READ> FOLLOWED BY <READ VALUE>
image


For sensors we have previously used, for example, MAX30101 (datasheet), the read sequence looks like
image

This I2C sequence can be achieved by the following commands

_i2c->beginTransmission(_address);
_i2c->write(reg);       // Register address
_i2c->endTransmission();
_i2c->requestFrom(_address, 1); // request 1 byter of data
_i2c->read();

However, there seems to be no support in the Wire library to send <SEND ADDRESS IN READ MODE> <REGISTER TO READ>.
I think the intended use of the Wire library to read a register is:

  1. send device address in write_mode (LSB=0)
  2. send register address
  3. send device address in read_mode (LSB=1)
  4. read bytes of data sent from the slave
    I could not find a API to create the I2C timing diagram we need.

References:

  1. Understanding the I2C Bus
  2. I2C - - — Arduino ESP32 latest documentation
  3. Wire | Arduino Documentation
  4. Read KTD2026 registers without tx command - Nordic Q&A - Nordic DevZone - Nordic DevZone

Logic Analyzer output

  • Using the logic analyzer, you can confirm that
    1. Writing to the register works as expected since it fits the i2c timing diagram as specified in the datasheet
    2. However, reading a register usinghte Wire library implementation goes against the KTD2026 datasheet, and hence, we are unable to read a register from the IC
      image
@nitin710 nitin710 added the bug Something isn't working label Nov 22, 2024
@nitin710
Copy link
Contributor Author

I'm relatively convinced that we need a different implementation of the requestFrom function to be able to read data from the IC. In the absence of this function, I am proceeding with having internal register stated in the driver itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant