IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
Showing results for 
Search instead for 
Did you mean: 

Knowledge Base Articles

I2C Read/Write in FX2LP - KBA224159


I2C Read/Write in FX2LP - KBA224159

Version: **

Translation - Japanese: FX2LPでのI2C読み取り/書き込み - KBA224159 - Community Translated (JA)


How can I perform an I2C read followed by an I2C write in FX2LP?


The EZUSB.LIB library can be used for performing I2C read/write in FX2LP. To perform an I2C write and read back the data from an I2C slave device, use the following sequence of commands:

BYTE xdata BUFFER[2];

DATA01[2] = { 0x00, 0xAA }      // First byte indicates the internal address of EEPROM

                              // Second byte indicates the data to be written                     

//I2C Write

EZUSB_WriteI2C(0x50, 0x02, DATA01);     // Write the data to the slave device with address 0x50

EZUSB_WaitForEEPROMWrite(0x50);         // Wait until the I2C write is completed

//I2C Read

EZUSB_WriteI2C(0x50, 0x01, DATA01);   // Write the internal slave address from which the data is  to be read

EZUSB_ReadI2C(0x50, 0x01, BUFFER[0]); // Read the data from the slave device and store it in BUFFER

Version history
Revision #:
1 of 1
Last update:
‎Jun 26, 2018 12:49 AM
Updated by: