- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi sir,
i encounter an issue of accessing a image sensor via i2c.. might need a recommendation for properly debugging..
The register of the sensor has 2 bytes address , and 2 byte value, the slave address is 0x20..
basically, the sensor indeed returns ACK, right after sending slave address (0x20), there is no i2c slave address conflict.
i wanna read 2 bytes data from 2 bytes register, which has 0x3000 address..
when i send a i2c read commands, the sensor seems never returnning ACK after 0x21 (read command), attaching the i2c waveform below.
the i2c waveform above after decode as below.
20 30 00 21#
S: Start signal
# -> NAK
the sensor never returns the data, but NACK..
error code returned is
ImageSensorSensorRead Failed addr=0x3000, status = 0x4A
the actual code being sent as below ..
for(cnt=0; cnt<3 ; cnt++) //
{
preamble.buffer[1] = CY_U3P_GET_MSB (regAddr);
preamble.buffer[2] = CY_U3P_GET_LSB (regAddr);
preamble.buffer[3] = SENSOR_I2C_READ_ADDRESS; /* Slave address: Read operation */
preamble.buffer[0] = SENSOR_I2C_WRITE_ADDRESS; /* Slave address: write operation */
preamble.length = 4;
preamble.ctrlMask = 0x0004;
status = CyU3PI2cReceiveBytes (&preamble, buf, count,0);
SensorI2CAccessDelay(status);
CyU3PThreadSleep(1);
if (status == CY_U3P_SUCCESS)
{
break;
}
#ifdef SENSOR_DEBUG
else
CyU3PDebugPrint(4,"\r\nImageSensorSensorRead Failed addr=0x%x, status = 0x%x",regAddr, status);
#endif
}
return status;
thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We don't need specific caution on CX3 I2C part. The values of 2.2k/4.7k which are commonly used should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Could you please provide some detail about SensorI2CAccessDelay() function. Please check error status immediately after CyU3PI2cReceiveBytes(). I assume that the SENSOR_I2C_READ_ADDRESS & SENSOR_I2C_WRITE_ADDRESS are in the I2C spec.
Bit 7 - 1: Slave address.
Bit 0 : 0 - Indicating this is a write/read from master.
If not please confirm.
Thanks & Regards
Abhinav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
over here.
static void SensorI2CAccessDelay( CyU3PReturnStatus_t status)
{
//
// Add a 10us delay if the I2C operation that preceded this call was successful.
//
if (status == CY_U3P_SUCCESS)
CyU3PBusyWait(10);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Akeem,
-Which sensor are you going to interface with CX3? Please kindly check the hardware design according to the application note/datasheet from sensor vendor.
-Please check if the sensor is well initialized(reset and power) and if it is ready for receiving data from I2C port. Generally speaking, sensors will not ACK I2C command if it is not well intialized.
-Please check if you set the correct W/R slave address in firmware. It is common that a sensor has two or more I2C address according to different connection condition.
-It is strange that the amplitude of SCL/SDA drops from your screenshot. Check if anything abnormal on your I2C hardware part.
- I recommend you capture the I2C communication with logic analyzer. It is easy to check what happened on I2C port.
- Do you modify the definition of SensorI2CAccessDelay? Try to print the error code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for the recommendation,
i think it could likely issue of value of i2c pull up... looks like that CX3 doesn't have internal pull for SDA and SCL. so i have to wire them externally.
Does CX3 have a recommendation for specific value of pull up resistor?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We don't need specific caution on CX3 I2C part. The values of 2.2k/4.7k which are commonly used should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks.
the issue was resolved by proper value of pull-up resistor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Congratulations to you. I will close this ticket later.