1 Reply Latest reply on Aug 26, 2010 8:13 AM by zenith.thomsan

    I2C issues on CY7C68013A

    zenith.thomsan

      I am using CY3684 board to test my code. I want to write some data on EEPROM(C2 load on 128). The code is supposed to be the simplest but it does not work.. I am posting my main code here. I also tried tweaking 'EZUSB_EEPROMWrite' function inside i2c.c provided by cypress, but that does not have any effect. So i am also including i2c.c for reference as attachment. I am using Keil uV3 to compile the code.

         

      //Main code for writing data into LgEEPROM. The data is any random data

         

      #include <fx2.h>
      #include <fx2regs.h>
      #include "i2c.c"

      void main(void)
      {

      EZUSB_InitI2C();

      EZUSB_WriteI2C(0xC2,0x01,0x00);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x02);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x01);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x09);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x02);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x01);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x03);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x00);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x10);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x00);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x02);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x12);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x00);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x02);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x14);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x01);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0xe2);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x16);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x02);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x82);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x20);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x00);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0xd0);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0xC2);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x00);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x08);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x25);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x06);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x26);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x5B);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x27);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x9A);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x30);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x10);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x31);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x10);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x32);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x10);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x33);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x10);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x34);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x17);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x35);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x7F);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x40);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0xFF);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x41);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x7F);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x42);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x7F);EZUSB_WaitForEEPROMWrite(0xC2);

      EZUSB_WriteI2C(0xC2,0x01,0x43);EZUSB_WaitForEEPROMWrite(0xC2);
      EZUSB_WriteI2C(0xC2,0x01,0x7F);EZUSB_WaitForEEPROMWrite(0xC2);
      }

         

      Thanks !