Giter VIP home page Giter VIP logo

Comments (5)

pasko-zh avatar pasko-zh commented on July 23, 2024

I suspect some timing issues while reading from the slave during/after ADC.

According to the datasheet it is also possible to read from the config register. Thus, could try to write to the config register value x and read it back? And repeat this with a value y? If you get different values back, i.e. x and y then the basic i2c communication is fine and we have to look deeper at the ADC part.

from brzo_i2c.

k-korn avatar k-korn commented on July 23, 2024

Thanks, have tried reading back the config register now.
Results are positive with Wire library: value written can be immediately read back with no issues.

With bgzo_i2c, however, value received back after writing does not match the one I've attempted to write.
Moreover, in the following sequence:

  • Flash Wire example
  • Write config register with value X, read back, confirm it's the same.
  • Without powering down ADS1015, flash brzo_i2c example into the ESP
  • Write value Y to the config register
  • Read it back

I am actually receiving back value X, which has been written previously with Wire example.

So I assume, brzo_i2c can read data. But it's having issues writing 2-byte config register.

from brzo_i2c.

pasko-zh avatar pasko-zh commented on July 23, 2024

I had a closer look at the datasheet. Figure 17 shows the expected i2c communication:
image

In other words:

i. START
ii. Slave Address
iii. Send Pointer Register (1 Byte)
iv. Send Data (here in the example 2 Bytes)
v. STOP

However, what you are sending is:

  1. START
  2. Slave Address
  3. Pointer Register (1 Byte)
    (NO STOP)
  4. (REPEATED) START
  5. Slave Address
  6. Data (2 Bytes)
  7. STOP

In your code brzo_i2c_write(buffer,1, true); corresponds to 1., 2., 3. then brzo_i2c_write(buffer,2,false); corresponds to 4., 5., 6., 7.

Note that the wire library behaves differently, see the wiki.

That's why the wire library code works.

So, what you need to do is:

  • Use a buffer of three bytes
  • Put all the data (Pointer Register and the bytes for config register) in the buffer
  • Send it all together, i.e. call brzo_i2c_write(buffer,3,false);

from brzo_i2c.

k-korn avatar k-korn commented on July 23, 2024

Thanks a lot, the following actually works:

    uint8_t buffer[3];
    brzo_i2c_start_transaction(ADS1X15_ADDRESS, BRZO_I2C_SPEED);
    buffer[0] = 1;
    buffer[1] = (uint8_t)(cfg_value >> 8);
    buffer[2] = (uint8_t)(cfg_value & 0xFF);
    brzo_i2c_write(buffer,3,false);

    rc = brzo_i2c_end_transaction();

from brzo_i2c.

pasko-zh avatar pasko-zh commented on July 23, 2024

You are welcome. I've updated the wiki on how to migrate from Wire Library to brzo, I hope it is better explained now.

from brzo_i2c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.