- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm using PSoC 5LP I2C Master device. I have to read and write from a slave device which has sub-addresses. I'm able to write to the device, now I want to read back what I wrote to verify that the writes are done. My example code for write is given below. How would I do something similar for read.
Thanks.
uint8 temp = 0;
i2c_slv_addrs = slave_address >> 1; // I2C slave address, shift right by 1 bit, 7 bits addressing
slave_sub_reg[0] = sub_address; // sub address
slave_sub_reg[1] = data_to_write; // data to write
do
{
temp = I2C_MasterWriteBuf(i2c_slv_addrs, (uint8 *)slave_sub_reg, 2 , I2C_MODE_COMPLETE_XFER);
}
while (temp != I2C_MSTR_NO_ERROR);
// stay here until full xfer is done
while(I2C_MasterStatus() & I2C_MSTAT_XFER_INP);
temp = HDMI_I2C_MasterClearStatus();
// If there is an error while transferring data
if(temp & HDMI_I2C_MSTAT_ERR_XFER)
{
// Indicate the error
}
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please refer to I2C master examples in PSoC Creator.
Thanks,
Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, any chance you could upload your design?
Thanks,
Joe