Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > regarding of i2c read , write not working. what am i do chip id in i2c?

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



regarding of i2c read , write not working. what am i do chip id in i2c?
Moderator:
RSKV

Post Reply
Follow this topic



regarding of i2c read , write not working. what am i do chip id in i2c?

dv2 posted on 27 Dec 2012 8:25 AM PST
Top Contributor
113 Forum Posts

Hi.

I working i2c with fx2lp.

My i2c chip address is 0x23. and  i2c address 8bit and data 8bit.

I want write  address 0x18 , data 0x37. So how do i make i2c command line?

Could you please let me know where is not correct and how can i fix?

Firmware :

 

BOOL DR_VendorCmnd( void )

{

BYTE addr;

BYTE fail;

BYTE count;

  BYTE tmp;

 

WORD wValue;

WORD wIndex;

 

wValue = SETUPDAT[2];

wValue |= SETUPDAT[3]<<8;

 

wIndex = SETUPDAT[4];

wIndex |= SETUPDAT[5]<<8;

 

  

  switch (SETUPDAT[1])

  {

case VENDOR_CMD1: 

 

EZUSB_InitI2C();

Cmd1[0] = 0x02;

while(EZUSB_WriteI2C(0x23 >> 1, 0x01, Cmd1) != I2C_OK) {

;

}

EZUSB_WaitForEEPROMWrite(0x23 >> 1);

 

Cmd1[0] = 0x37;

while(EZUSB_WriteI2C(0x18 >> 1, 0x01, Cmd1) != I2C_OK) {

;

}

EZUSB_WaitForEEPROMWrite(0x18 >> 1);

 

EZUSB_ReadI2C(0x18 >> 1, 0x01, Cmd1);

EP0BUF[0] = Cmd1[0];

EP0BCH = 0;

EP0BCL = 1;

EP0CS |= bmHSNAK; // Acknowledge handshake phase of device request

break;

default:

   return(TRUE);

  }

 

  return(FALSE);

}

 

 

 

PC application side :

 

if(init_USB()){

ept0 = USBDevice->ControlEndPt;

ept0->Target = TGT_DEVICE;

ept0->ReqType = REQ_VENDOR;

ept0->Direction = DIR_FROM_DEVICE;

ept0->ReqCode = 0xDA;

ept0->Value = ii;

ept0->Index = 0x00;

unsigned char buf[2];

ZeroMemory(buf,2);

LONG buflen = 2;

ept0->Read(buf,buflen);

UpdateData(FALSE);

}

 

 

 

Please let me know where am i do fix ?

 




Re: regarding of i2c read , write not working. what am i do chip id in i2c?

Gayathri posted on 08 Jan 2013 02:10 AM PST
Cypress Employee
428 Forum Posts

 Hi,

 

Refer the implementation of vendor commands "VR_EEPROM' in the AN project: Vendor Command Design Guide for the FX2LP (http://www.cypress.com/?rID=34485). This might help you.

 

Regards,

Gayathri






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.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20