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

USB superspeed peripherals Forum Discussions

LBence91
Level 4
Level 4
10 questions asked 50 sign-ins 25 replies posted

Hello,

Currently I am working the FX3. The AN75779 example code I accomplished I2C communication with multiple devices, but when I tried to communicate with a MCP4552 digital potentiometer the CyU3PI2cTransmitBytes function always returns with a 74 value. I was not able to find the meaning of this error code. Because I already using the I2C lines with other devices I think I will find the error in the datasheet, but for debugging the error I need to understand the status code.

Copied the I2C implementation I tried it with and without the CyU3PI2cWaitForAck(&preamble,0) line, with the same results.

CyU3PReturnStatus_t digi_i2c_write(uint8_t slave_addr, uint8_t reg_addr, uint8_t data)
{
	CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
	CyU3PI2cPreamble_t  preamble;
	uint8_t buf[2];

	/* Validate the I2C slave address. */
	if ((slave_addr != DIGITPOT_ADDR_W) && (slave_addr != I2C_MEMORY_ADDR_WR))
	{
		CyU3PDebugPrint (4, "I2C Slave address is not valid!\n");
		return 1;
	}

	/* Set the parameters for the I2C API access and then call the write API. */
	preamble.buffer[0] = slave_addr;
	preamble.buffer[1] = reg_addr;
	preamble.length    = 2;             /*  Three byte preamble. */
	preamble.ctrlMask  = 0x0000;        /*  No additional start and stop bits. */
	buf[0] = data;
	apiRetStatus = CyU3PI2cTransmitBytes (&preamble, buf, 1, 0);
	CyU3PI2cWaitForAck(&preamble,0);
	SensorI2CAccessDelay (apiRetStatus);

	return apiRetStatus;
}

Best Regards,

Bence

0 Likes
1 Solution
AliAsgar
Moderator
Moderator
Moderator
750 replies posted 50 likes received 500 replies posted

Hi Bence,

Error code 74 = 0x4A corresponds to ERROR_FAILURE. Please find the exact error code by calling the CyU3PReturnStatus_t CyU3PI2cGetErrorCode ( CyU3PI2cError_t *error_p ) API after the transmitBytes API call. Please share the error output with us.

Please share the I2C logic analyser traces with us when the issue is seen.

Try keeping the number of retries value as 10 instead of 0 for the transmitBytes and WaitForAck API and check if the issue is resolved.

Best Regards,
AliAsgar

 

 

 

View solution in original post

0 Likes
4 Replies
AliAsgar
Moderator
Moderator
Moderator
750 replies posted 50 likes received 500 replies posted

Hi Bence,

Error code 74 = 0x4A corresponds to ERROR_FAILURE. Please find the exact error code by calling the CyU3PReturnStatus_t CyU3PI2cGetErrorCode ( CyU3PI2cError_t *error_p ) API after the transmitBytes API call. Please share the error output with us.

Please share the I2C logic analyser traces with us when the issue is seen.

Try keeping the number of retries value as 10 instead of 0 for the transmitBytes and WaitForAck API and check if the issue is resolved.

Best Regards,
AliAsgar

 

 

 

0 Likes

Hi AliAsgar,

Thank you for your fast response. I added the CyU3PI2cGetErrorCode call the result of the function is 65! I recorded I2C lines during the communication:

slave address is 0x5E and the register address is 0x80 the data is missing.

SDS2104X Plus_PNG_6.png

0 Likes

There was a problem with the addressing not the API Call. Thank you. Is there an available list where can I find the meaning of the error codes for debugging future problems?

0 Likes
AliAsgar
Moderator
Moderator
Moderator
750 replies posted 50 likes received 500 replies posted

Hi Bence,

Glad to hear that your problem is resolved.

All the return status/error codes can be seen from the cyu3error.h file.

Best Regards,
AliAsgar

0 Likes