CX3 SDK-1.3: Facing issue with I2C Communication

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GaK_4661021
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

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,

devAddr = 0x3C;

preamble.length = 4;

preamble.buffer[0] = devAddr;
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;
}
Can anyone point out the probable issue? Am I doing anything wrong with I2C communication?
0 Likes
1 Solution

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

View solution in original post

0 Likes
10 Replies
cycy_1740621
Level 4
Level 4
First comment on KBA 10 solutions authored 25 replies posted

Could you check the waveform on I2C bus?

To make thing simple, try to read one register and capture the waveform.

0 Likes

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?

0 Likes

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

0 Likes

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?

0 Likes

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()

0 Likes

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?

0 Likes

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

0 Likes

Yes.

We are able to perform both write and read operation with 0x78 and 0x79 slave address respectively.

0 Likes

Hello,

Thank you for the confirmation.
The behavior is expected based on I2C addressing as mentioned above.

Regards,
Yashwant

0 Likes

Thanks for the help.

0 Likes