I2C_SensorWrite CyU3PI2cTransmitBytes fail error 0x4a

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

cross mob
yaqi_4776616
Level 4
Level 4
50 sign-ins 25 replies posted 25 sign-ins

Hello,

When I was debugging the CX3 UVC project, I found that CyU3PI2cTransmitBytes in I2C_SensorWrite returned the error value 0x4a

yaqi_4776616_0-1615893949631.png

yaqi_4776616_1-1615893995360.png

The error represented by 0x4a is CY_U3P_ERROR_FAILURE - When a transfer fails with an error defined in CyU3PI2cError_t

yaqi_4776616_2-1615894056936.png

I found the mistake, but what I have to do next to correct the mistake I have no idea,I hope you can give me some advice to help me, thank you very much!

Best Regards,

Yaqi

0 Likes
1 Solution

Hello,

Please check the if the sensor and CX3 I2C voltage levels are same.

I still encounter the same error, using an oscilloscope to check, I found that the SDA only shows the slave address and there is no ACK after it.

>> From this it seems that the problem is from the sensor end or in the voltage level of I2C line. Please check the I2C lines voltage level and confirm if it is as expected

 Is it possible that the problem is with the I2C communication, or is it with my sensor?

>> If the voltage level on I2C lines are as expected (i.e. compatible with the voltage level supported by sensor) then it seems that the problem is with sensor.

Regards,
Rashi

View solution in original post

0 Likes
9 Replies
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

Please refer to section 10.19.2 I2C_STATUS of FX3 TRM for  status register which can be read to get the error details. The register can be read using this API CyU3PReadDeviceRegisters. Based on the register value we can know the cause of the error. Please read the register when the issue is seen and let us know the value.

Please confirm if the pullup resistors are used on the I2C lines as recommended in AN70707 app note.

Regards,
Rashi
0 Likes
yaqi_4776616
Level 4
Level 4
50 sign-ins 25 replies posted 25 sign-ins

Hi Rashi,

I found this CyU3PI2cGetErrorCode () API,This function can be used to retrieve the actual I2C error code once the register
mode I2C transfer APIs have returned the CY_U3P_ERROR_FAILURE error code.Now I want to call this API, but I don't know CyU3PI2cGetErrorCode (
CyU3PI2cError_t *error_p /**< Return pointer to be filled with the error code.
); the parameter *error_p should be changed to what,Can you help me make sure?Thank you.

yaqi_4776616_0-1616035553081.png

Best Regards,

Yaqi

0 Likes

Hello,

Please try this and let me know if you are able to compile the firmware and get the error code

CyU3PI2cError_t error;
/..../

status = CyU3PI2cTransmitBytes (&preamble, buffer,count , 0);
            if (status != CY_U3P_SUCCESS)
            {
            	CyU3PI2cGetErrorCode(&error);
            	CyU3PDebugPrint (4, "I2C error code = %d", error);

                return status;
            }

Please let me know the value of variable error and also check if  CyU3PI2cGetErrorCode returns CY_U3P_SUCCESS

Regards,
Rashi
0 Likes
yaqi_4776616
Level 4
Level 4
50 sign-ins 25 replies posted 25 sign-ins

Hi

I changed the code to the following figure and debugged it, the result status = CyU3PI2cTransmitBytes (&preamble, buf, count,0) status returned 0x4a, status = CyU3PI2cGetErrorCode(&error) status returned 0.

yaqi_4776616_0-1616040961015.png

What is the problem? What do I do next?

Best Regards,

Yaqi

0 Likes
yaqi_4776616
Level 4
Level 4
50 sign-ins 25 replies posted 25 sign-ins

error = CY_U3P_I2C_ERROR_NAK_BYTE_0

yaqi_4776616_1-1616041409442.png

 

0 Likes

Hello,

From the description, I understand that CyU3PI2cTransmitBytes was failing. But in your latest response the CyU3PI2cGetErrorCode API is called in error handler of CyU3PI2cReceiveBytes.

Please let me know the exact problem so that I can help you better.

The error CY_U3P_I2C_ERROR_NAK_BYTE_0 means that Slave NACK-ed the zeroth byte of the preamble. Please check if the slave/sensor address (SENSOR_I2C_READ_ADDRESS/SENSOR_I2C_WRITE_ADDRESS) is correct and also confirm that appropriate structure (SENSOR_WriteConfigurationSettings_Regx) is used  as per register size of the sensor.

 I2C lines can be probed to check the status and traces can be shared for us to check.

Also confirm that the pullup resistors are used on the I2C lines as recommended in AN70707 app note

Regards,
Rashi
0 Likes
yaqi_4776616
Level 4
Level 4
50 sign-ins 25 replies posted 25 sign-ins

Hi

The sensor read and write addresses are correct, I tried I2C communication with CX3 MIPI part and it worked. When I communicate with the sensor I still encounter the same error, using an oscilloscope to check, I found that the SDA only shows the slave address and there is no ACK after it.
Now is it possible to be sure that the I2C communication is normal and the problem may be with my sensor hardware part?
But my sensor power measurement indicators are normal, I am now confused.
Is it possible that the problem is with the I2C communication, or is it with my sensor?

Best Regards,

Yaqi

0 Likes

Hello,

Please check the if the sensor and CX3 I2C voltage levels are same.

I still encounter the same error, using an oscilloscope to check, I found that the SDA only shows the slave address and there is no ACK after it.

>> From this it seems that the problem is from the sensor end or in the voltage level of I2C line. Please check the I2C lines voltage level and confirm if it is as expected

 Is it possible that the problem is with the I2C communication, or is it with my sensor?

>> If the voltage level on I2C lines are as expected (i.e. compatible with the voltage level supported by sensor) then it seems that the problem is with sensor.

Regards,
Rashi
0 Likes
yaqi_4776616
Level 4
Level 4
50 sign-ins 25 replies posted 25 sign-ins

Hi Rashi

It seems to be a problem with my hardware, and now it has been taken to repair.Thank you for your help.

Regars,

Yaqi

0 Likes