EmotiBit / EmotiBit_KTD2026

Driver for the KTD2026
MIT License
0 stars 0 forks source link

Issues reading register contents from the IC #2

Open nitin710 opened 7 hours ago

nitin710 commented 7 hours ago

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:

  5. Understanding the I2C Bus
  6. I2C - - — Arduino ESP32 latest documentation
  7. Wire | Arduino Documentation
  8. Read KTD2026 registers without tx command - Nordic Q&A - Nordic DevZone - Nordic DevZone

Logic Analyzer output

nitin710 commented 7 hours ago

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