Comments (5)
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.
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.
I had a closer look at the datasheet. Figure 17 shows the expected i2c communication:
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:
- START
- Slave Address
- Pointer Register (1 Byte)
(NO STOP) - (REPEATED) START
- Slave Address
- Data (2 Bytes)
- 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.
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.
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)
- I2C stucks after clock stretching time exceeds HOT 25
- Question: Logic Levels and ... HOT 2
- Cannot compile for Heltec Wifi Kit 32 HOT 3
- INA219 HOT 8
- Multiple I2C HOT 2
- gpio_init() will cause I2C bus busy (code: 1) HOT 5
- AM2320 sensor not found HOT 11
- I2C bus handle for multiple instances posibility HOT 1
- Support speeds < 100KHz HOT 2
- after 1 slave fails others stop working HOT 4
- Have you thought about a i2c slave implementation. HOT 2
- Novice obsession HOT 2
- GCC 10 compilation issue with Arduino HOT 5
- SDA set before SCL while preparing STOP in brzo_i2c_read() HOT 7
- MEMW not always present
- Clock stretch logic
- Arduino IDE compile error with new ESP8266 core 3.0.0 HOT 30
- SCL cock stretching HOT 3
- Platformio installation instructions confusing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brzo_i2c.