How to read I2C from chip that does not use traditional registers but commands
10 次查看(过去 30 天)
显示 更早的评论
I am using Matlab R2022A to control a number of chips via I2C bus. (I am using an Arduino on a USB port to interface to my I2C bus, using the Arduino support package.)
For some chips I am unable to read back from the chip because these chips don’t use traditional register addresses but commands to tell the chip what to return. For example AD5272 by Analog Devices:
For reading back, the device expects the master to first send 3 bytes: Device address, followed by two more bytes.
Function ‘readRegister’ allows me to send only two bytes: The device address, followed by the register address. (And it reads back only 1 byte but I need to read 2.)
Function ‘read’ allows me to send only the device address so that also doesn’t work.
Is there any other (low level) read function that I can use to first send 3 bytes (instead of 2)?
0 个评论
采纳的回答
Anush
2023-6-21
Hello Johannes,
You can make use of the AD5272 Datasheet to come up with a suitable workflow for the read operation.
The datasheet provides essential information regarding the read operation, including:
'When reading data back from the AD5272/AD5274, the user must first issue a readback command to the device, this begins with a start command followed by an address byte (R/W = 0), after which the AD5272/AD5274 acknowledges that it is prepared to receive data by pulling SDA low. Two bytes of data are then written to the AD5272/AD5274, the most significant byte followed by the least significant byte; both of these data bytes are acknowledged by the AD5272/AD5274. A stop condition follows'
You can use the write(dev,dataIn) function to first write the readback command with device address followed by the two bytes of data and then make use of the read() function to get the data back.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!