Clear Filters
Clear Filters

Raspberry Pi I2C readRegister returning spurrious values

2 views (last 30 days)
Have connected a ADR5593R to a Raspberry Pi and am able to see it on the I2C bus but when i try to read any register i get a random number which does not agree with that registers default value. This number is the same for all registers but changes if i reset the chip. Code I am using is:
mypi=raspi;
writeDigitalPin(mypi,23,1) %connected to the chip's reset pin
adc= i2cdev(mypi,'i2c-1','0x11');
[value]=readRegister(adc,3,'uint16');
Am i using the readRegister command incorrectly?

Answers (1)

Sumit Tiwari
Sumit Tiwari on 31 Jul 2015
Hi Nathan,
It is my understanding that you are trying to read data from your sensor/converter using the I2C protocol.
Unfortunately, without the specifics of your design, it is very hard to pinpoint where things are going wrong. But one way to ensure the correctness of your design would be to gather the data from these registers yourself (using a Linux shell terminal), and compare it with the results you see in MATLAB.
To do so, you first need to install the 'i2c-tools' package on your board and load its driver module. You can follow the instructions here to do so here: http://skpang.co.uk/blog/archives/575
Once the 'ic2-tools' package is installed, you can use its utilities to read and write data using your I2C bus. In your case, to read data from one of the chip registers, you would have to issue the 'i2cget' command appropriately. As an example, for a device connected at /dev/i2c-1 at address 0x49, to read a word from the currently selected register you would have to issue the following in your terminal:
i2cget -y 1 0x49 0 w
Further information on the 'i2cget' command can be found here: http://www.lm-sensors.org/wiki/man/i2cget
Once you obtain results by directly probing the Pi, you should be able to figure out any issues by comparing them with the results from MATLAB.
I hope this helps; feel free to post your results here.
Best,
Sumit
  1 Comment
Nathan
Nathan on 3 Aug 2015
We have done this and found the behaviour to be exactly the same as in Matlab, we also tried with an Arduino and got the same behaviour so i think the problem might lie with the chip or with the I2C lines as it seems to respond fine to address changes and resets etc. What specifics is it that you require exactly? Currently the chip is sat on a breadboard with the Vref, Vlogic and Vdd driven from the Pi's 3.3V out, GND, SCL and SDA connected to their relevant pins on the Pi (6, 5 and 3 respectively) and the Reset pin is connected to 23.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!