Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > FX3 dev board I2C EEPROM sample cyfxusbi2cregmode;

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



FX3 dev board I2C EEPROM sample cyfxusbi2cregmode;
Moderator:
RSKV

Post Reply
Follow this topic



FX3 dev board I2C EEPROM sample cyfxusbi2cregmode;

Vytautas2 posted on 06 Jan 2012 6:07 AM PST
Top Contributor
36 Forum Posts

Hi,

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)

#define CY_FX_USBI2C_I2C_SLAVE_ADDRESS  (0xE)

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 ?

Thanks.




Re: FX3 dev board I2C EEPROM sample cyfxusbi2cregmode;

aasi posted on 06 Jan 2012 07:12 AM PST
Cypress Employee
1073 Forum Posts

The address of EEPROM used is wrong. Please look at page 11 of the datasheet http://www.atmel.com/dyn/resources/prod_documents/doc0336.pdf

Regards,

Anand



Re: FX3 dev board I2C EEPROM sample cyfxusbi2cregmode;

Vytautas2 posted on 06 Jan 2012 07:40 AM PST
Top Contributor
36 Forum 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);

    else

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

    else

    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");

else

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

....
 
}
 



Re: FX3 dev board I2C EEPROM sample cyfxusbi2cregmode;

aasi posted on 06 Jan 2012 08:25 AM PST
Cypress Employee
1073 Forum 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?

Regards,

Anand



Re: FX3 dev board I2C EEPROM sample cyfxusbi2cregmode;

Vytautas2 posted on 09 Jan 2012 06:27 AM PST
Top Contributor
36 Forum Posts

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






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.