- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
We are using the CY7C65211 to communicate with a slave I2C device. I am having difficulties setting up the CyI2CRead. The register I want to read from is 0xA3 and I have been specifying the register that we need to read on the I2C device using the first address of the rbuffer, as shown below:
rbuffer[0]= 0xA3;
rbuffer[1]= 0
dataBufferRead.length = 1 ;
dataBufferRead.buffer = rbuffer;
rStatus = CyI2cRead (handle, &i2cDataConfig, &dataBufferRead, 5000);
When I check the I2C bus, the slave device address is correct, but the register byte is never correct. I am not sure if I have setup the send buffer correctly.
Can you provide help on how to setup a read from a slave device? Specifically how do I specify the register on the device that we want to read. I am running on Ubuntu kernel 5.10.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please provide the source code if it is not confidential?
Regards,
Meghavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Meghavi,
The source is below and is based on the example in the folder linux/testUtility that is provided by Infineon. What I am trying to do is read a register (0xA3) from device address (0x38). I am not sure how to specify the register address when I follow the example. When I test using the code below, the register bytes is never correct (i.e. not 0xA3 and it changes from one read to another) when I capture the signals on I2C bus.
int i2cTouchScreen (int deviceNumber, int interfaceNum)
{
CY_DATA_BUFFER dataBufferWrite, dataBufferRead;
CY_HANDLE handle;
int length = 0;
bool isVerify = true;
int loopCount = 100, i;
CY_RETURN_STATUS rStatus;
unsigned char bytesPending = 0, address[2], wbuffer[66], rbuffer[66];
CY_I2C_DATA_CONFIG i2cDataConfig;
memset (wbuffer, 0, 66);
memset (rbuffer, 0, 66);
i2cDataConfig.isStopBit = true;
i2cDataConfig.slaveAddress = 0x38;
rStatus = CyOpen (deviceNumber, interfaceNum, &handle);
if (rStatus != CY_SUCCESS){
printf("CY_I2C: Open failed %d \n",rStatus);
return rStatus;
}
rbuffer[0]= 0xA3;
rbuffer[1] = 0;
i2cDataConfig.isStopBit = true;
i2cDataConfig.isNakBit = true;
dataBufferRead.length = 1 ;
dataBufferRead.buffer = rbuffer;
rStatus = CyI2cRead (handle, &i2cDataConfig, &dataBufferRead, 5000);
if (rStatus != CY_SUCCESS){
printf ("Error doing i2c read ... Error is %d \n", rStatus);
CyClose (handle);
return -1;
}
printf ("\n Data that is read from i2c ...%d\n",dataBufferRead.length);
printf ("\n-----------------------------------------------------------------\n");
for (rStatus = 0; rStatus < 3; rStatus++){
printf ("%x ", rbuffer[rStatus]);
}
CyClose (handle);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Malcomflex,
This is a slave internal address and seems like it issues from the slave response.
can you please share what response you are getting from the slave?
Please share Datasheet and Logic analyzer signals from slave.
can you please share the Device datasheet with us, we need to check the address of the register.
Thank you
Varun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi MalcolmFlex,
can you please share the slave datasheet and analyzer signal?
Thank you
Varun Narolkar