You are here

FX3 dev board I2C EEPROM sample cyfxusbi2cregmode; | Cypress Semiconductor

FX3 dev board I2C EEPROM sample cyfxusbi2cregmode;

Summary: 4 Replies, Latest post by Vytautas2 on 09 Jan 2012 08:27 AM PST
Verified Answers: 0
Last post
Log in to post new comments.
Vytautas2's picture
36 posts


I try to test I2C sample cyfxusbi2cregmode with FX3 dev board and Atmel 24C64 EEPROM inserted to U44.

The problem is that it does not work (I2C Transmit Bytes failed, Error Code = 74).

I changed in .h file the following:

#define CY_FX_USBI2C_I2C_MAX_CAPACITY   (8*1024)

#define CY_FX_USBI2C_I2C_PAGE_SIZE   (32)


I would like to know how to calculate I2C EEPROM address for CyU3PI2cPreamble_t (preamble.buffer[0]).

On FX3 dev board all SW40 switches are away from "ON" text, so most likely this means that we have A0=1, A1=1, A2=1.

I assumed that in binary form preamble.buffer[0] parameter is created in the following way:

0 0 0 0 A2 A1 A0 RW => 00001110 => 0xE.

But this does not work. What may be wrong and how to make it work ?


aasi's picture
Cypress Employee
1166 posts

The address of EEPROM used is wrong. Please look at page 11 of the datasheet



Vytautas2's picture
36 posts

Changed address to 0xAE (10101110), but the result is the same - error 74.

Also I tried to create separate sample (based on cyfxisolpmaninout) for testing I2C EEPROM, but it also does not work (nor  CyU3PI2cReceiveBytes, nor CyU3PI2cTransmitBytes, nor CyU3PI2cWaitForAck).

#define CY_FX_USBI2C_I2C_BITRATE        (100000)

#define CY_FX_USBI2C_I2C_TIMEOUT        (0xFFFFFFFF)

static uint8_t tmp_i2c_test_buf[64];
static int tmp_i2c_test_buf_len = 1; // 64
void ApplnInit (void)


    CyU3PReturnStatus_t apiRetStatus;

    uint32_t txApiRetStatus;

    CyU3PI2cConfig_t i2cConfig;

    txApiRetStatus = CyU3PEventCreate(&glAppEvent);

    if (txApiRetStatus != 0)

        CyU3PDebugPrint (4, "Iso Loop Appln Create Event failed, Error Code = %d\n",txApiRetStatus);

    apiRetStatus = CyU3PI2cInit();

    if (apiRetStatus != 0)

    AppErrorHandler(4, "I2C Init failed, Error Code = %d.\r\n",apiRetStatus);


    CyU3PDebugPrint(4, "CyU3PI2cInit; OK;\r\n");

    i2cConfig.bitRate = CY_FX_USBI2C_I2C_BITRATE;

    i2cConfig.busTimeout = CY_FX_USBI2C_I2C_TIMEOUT;

    i2cConfig.isDma = CyFalse; // Use register mode

    i2cConfig.dmaTimeout = 0xFFFF;

    apiRetStatus = CyU3PI2cSetConfig(&i2cConfig, NULL);

    if (apiRetStatus != 0)

    AppErrorHandler(4, "I2C Set Config failed, Error Code = %d.\r\n",apiRetStatus);


    CyU3PDebugPrint(4, "CyU3PI2cSetConfig; OK;\r\n");


    int tmp_addr;

    CyU3PI2cPreamble_t preamble;

    tmp_addr = 0xAE;

preamble.buffer[0] = tmp_addr;

preamble.buffer[1] = 0; // address 0

preamble.buffer[2] = 0; // address 0

preamble.buffer[3] = tmp_addr | 0x1; // slave address; read

preamble.length = 4;

preamble.ctrlMask = 0x0004;


apiRetStatus = CyU3PI2cReceiveBytes (&preamble, tmp_i2c_test_buf, tmp_i2c_test_buf_len, 10);


//preamble.length = 1;

//apiRetStatus = CyU3PI2cWaitForAck (&preamble, 1);


if (apiRetStatus == CY_U3P_SUCCESS)

CyU3PDebugPrint (4, "*** OK or 0 bytes.\r\n");


CyU3PDebugPrint (4, "*** Failed to read from I2C EEPROM. Error Code = %d.\r\n",apiRetStatus);


    /* Start the USB functionality */

    apiRetStatus = CyU3PUsbStart();

    if (apiRetStatus != CY_U3P_SUCCESS)

        AppErrorHandler(4, "USB Function Failed to Start.\r\n", apiRetStatus);

aasi's picture
Cypress Employee
1166 posts

You can use the possible error code return documented for each API in the API user guide and the header file cyu3i2c.h to understand the reason behind the issue.

In your case 74 0x4A seems to be related to NAK, transfer failed etc. Is it possible to probe the I2C lines to see what exactly is happening on it?



Vytautas2's picture
36 posts

 The problem was in J42, J45 jumpers. Now I2C EEPROM read/write is ok, but still cannot boot with custom VID/PID.

Log in to post new comments.