cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

ThM_3776866
New Contributor II

Hi all,

I working on Fx-3 I2C interface. Fx-3  acts as master and stv0913 (Demod) and RDA5815S (Tuner) acts as slave.

In cypress I2C code as below.

CyU3PReturnStatus_t I2C_Write (  uint8_t slaveAddr, uint32_t count, uint8_t *buf)

{

CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

CyU3PI2cPreamble_t preamble;

CyU3PDebugPrint (1, "I2C Write operation - dev:0x%x, size: %d,\r\n",(slaveAddr<<1), count);

/* Update the preamble information. */

preamble.length    = 1;

preamble.buffer[0] = ((slaveAddr<< 1) | I2C_Operation_Write );

preamble.ctrlMask  = 0x0000;

status = CyU3PI2cTransmitBytes (&preamble, buf, count, 100);

if (status != CY_U3P_SUCCESS)

{

return status;

}

/* Wait for the write to complete. */

status = CyU3PI2cWaitForAck(&preamble, 100);

if (status != CY_U3P_SUCCESS)

{

return status;

}

/* An additional delay seems to be required after receiving an ACK. */

CyU3PThreadSleep (1);

return CY_U3P_SUCCESS;

}

Note 1: this function i am using 2 API

           1. status = CyU3PI2cTransmitBytes (&preamble, buf, count, 100);

           2. status = CyU3PI2cWaitForAck(&preamble, 100);

1. This code is working fine for Demod I2C write operation ( I am able to wirte the data to specific memory and i can read the data from same memory). the above 2 API gives status as CY_U3P_SUCCESS.

2.   If i am try to writing data to tuner i am getting CY_U3P_SUCCESS after calling status = CyU3PI2cTransmitBytes (&preamble, buf, count, 100); API. But I am getting status value 74 after calling status = CyU3PI2cWaitForAck(&preamble, 100); this API.

Note 2: 1. if i am sending only I2C_slave address with count value=0 its working fine.

          1. if i am sending  I2C_slave address with count >0 its not working.

I probed the I2C bus with CRO. i am getting ACK at 9th clock cycle of every byte i attached the Image also ( slave address is 0x18).

tuner.png

Note 3: If i am writing the data to tuner to some register, i am getting status value 74 (CyU3PI2cWaitForAck) means NACK. But i am able to read the same register its giving the correct value what i sent in previously.

Q1. why i am getting error code 74? if slave responding a ACK signal.

Thank you

With Best Regards,

Thrimurthi M

0 Likes
1 Solution
KandlaguntaR_36
Moderator
Moderator

Thrimurthi,

You can read the memory location directly as follows:

CyU3PDebugPrint(4," I2C_STATUS  = %x\r\n", *(uvint32_t *) 0xE0000404);

View solution in original post

4 Replies
abhinavg_21
Moderator
Moderator

Hi Thrimurthi,

You are getting "CY_U3P_LPP_I2C_ERROR" because of some error in I2C communication. Please try to read "I2C Status Register" address "0xE0000404" after CyU3PI2cWaitForAck() API using UART debug logs and check if any error bit has raised.

Thanks & Regards
Abhinav

0 Likes
ThM_3776866
New Contributor II

Hi Abhinav sir,

How i to read I2c Status register value?.

0 Likes
KandlaguntaR_36
Moderator
Moderator

Thrimurthi,

You can read the memory location directly as follows:

CyU3PDebugPrint(4," I2C_STATUS  = %x\r\n", *(uvint32_t *) 0xE0000404);

View solution in original post

ThM_3776866
New Contributor II

Thank You  KandlaGunta R.

0 Likes