How to read I2C from chip that does not use traditional registers but commands

9 views (last 30 days)
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)?

Accepted Answer

Anush
Anush on 21 Jun 2023
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.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!