Difficulty with i2c Read Register. Not enough information in the doc

3 ビュー (過去 30 日間)
Robert 2017 年 1 月 24 日
コメント済み: Walter Roberson 2020 年 4 月 7 日
So i am working with an I2C device and reading in 8 bit register data
The problem is the following. The doc does not allow for data to be read in a specific format.
The register is currently housing data in a 2,s complement format
When i read from the register its giving decimal answers.
This is a problem because i have no idea what conversion its doing in the background. It sure doesn't know that what its reading is 2s complement so I'm assuming the decimal number I'm getting back is wrong also.
How can i just read the register in pure binary?
There is nothing in the doc


Walter Roberson
Walter Roberson 2017 年 1 月 24 日
If you are using arduino and read() of an i2cdev object, then the transfer always binary. As is always the case, by default MATLAB displays binary numbers in decimal . You can use dec2bin() to display it as binary.
I suspect that want you want is to pass 'int8' to the read() routine.
  8 件のコメント
Walter Roberson
Walter Roberson 2020 年 4 月 7 日
Understanding the I2C Bus
Data is transferred Most Significant Bit (MSB) first.
As the bit order for I2C is fixed, there is no possibility that the bit order for any given device should be the other way around. This is not a negotiable property of the device.


その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by