- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am facing an issue while reading the register of the OV5640 Camera sensor (I2C slave device in my setup) from firmware with "CyU3PI2cReceiveBytes" API through I2C. However, The camera module is working fine as I am able to stream it from Windows Host.
CyU3PI2cReceiveBytes returns CY_U3P_ERROR_FAILURE. I have further debugged the issue with "CyU3PI2cGetErrorCode" and it returns CY_U3P_I2C_ERROR_NAK_BYTE_0. Please find the code snippet below,
preamble.buffer[1] = 0x30;
preamble.buffer[2] = 0x2A;
preamble.buffer[3] = devAddr | 0x01 ;
preamble.ctrlMask = 0x0004;status = CyU3PI2cReceiveBytes (&preamble, buffer, 1, 0);
CyU3PThreadSleep(1);
if (status != CY_U3P_SUCCESS)
{
CyU3PI2cGetErrorCode(&errorCode);
return errorCode;
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
As mentioned in the following link:https://www.totalphase.com/support/articles/200349176-7-bit-8-bit-and-10-bit-I2C-Slave-Addressing
The I2C slave address of OV5640 is 0x3C but that isn't the case for the I2C READ and I2C WRITE addresses.
The I2C WRITE address will be (0x3C << 1) = 0x78
The I2C READ address will be (0x3C << 1 | 1) = 0x79
We are able to perform I2C operation with slave address 0x78.
=> Can you please confirm if this is a write operation or read operation that was successful?
If this was the write operation, then according to the above, this is expected.
Hope this helps.
Regards,
Yashwant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you check the waveform on I2C bus?
To make thing simple, try to read one register and capture the waveform.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Currently, I don't have access to DSO so I am unable to probe the pins. But as per my understanding if the OV5640 initialization sequence is working fine then another I2C request should work as OV5640 initialization sequence will be performed on I2C only. Is that any other way to look into it apart from pin probing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Can you please confirm if you are calling the CyU3PI2cReceiveBytes() API right after the CyU3PMipicsiInit() or is it before that?
You can go through the following thread with similar issue: CX3 connect MAX9296A MiPi issue
You can try calling the CyU3PI2cReceiveBytes API before CyU3PMipicsiInit() or after CyU3PMipicsiSetSensorControl() and see if that solves the issue.
Regards,
Yashwant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We are getting the same result in mentioned scenario as well.
We have probed I2C pins and observed that on I2C bus we are unable to get ACK for I2C write command. Is slave address 0x3C is correct for OV5640 image sensor?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The slave address for OV5640 is 0x3C.
Can you please try the following in you firmware:
1.) Try calling the CyU3PI2cReceiveBytes() API before CyU3PMipicsiInit() and see if you see the same issue again or not.
OR
2.) Try calling the CyU3PI2cReceiveBytes() API after the CyU3PMipicsiSetSensorControl() API and share the results.
Please try these and share the results.
Regards,
Yashwant
CyU3PMipicsiInit()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We are able to perform I2C operation with slave address 0x78. I have found in some post and some firmware example also that they are using address 0x3C and 0x3D for read and write operation respectively. I am wondering how does it work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
As mentioned in the following link:https://www.totalphase.com/support/articles/200349176-7-bit-8-bit-and-10-bit-I2C-Slave-Addressing
The I2C slave address of OV5640 is 0x3C but that isn't the case for the I2C READ and I2C WRITE addresses.
The I2C WRITE address will be (0x3C << 1) = 0x78
The I2C READ address will be (0x3C << 1 | 1) = 0x79
We are able to perform I2C operation with slave address 0x78.
=> Can you please confirm if this is a write operation or read operation that was successful?
If this was the write operation, then according to the above, this is expected.
Hope this helps.
Regards,
Yashwant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes.
We are able to perform both write and read operation with 0x78 and 0x79 slave address respectively.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thank you for the confirmation.
The behavior is expected based on I2C addressing as mentioned above.
Regards,
Yashwant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the help.