Raspberry Pi I2C readRegister returning spurrious values
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Sumit Tiwari
2015-7-31
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Run on Target Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!