2 Replies Latest reply on May 29, 2012 3:32 AM by moon.young.joo

    i2c question

    moon.young.joo

      In dvk board schematic, I2C(24LC256) address can be only  3 wire-configurable. So I think that the address range is 0X00 to 0X07.

         

      But inthe sdk i2c regmode example, the address is always set to 0xA0~0XA7,can you explain the meaning of A........

         

      IN EP0 Function, CyFxUSBSetupCB(.........)

         

      i2cAddr = 0xA0 | ((value & 0x0007) << 1);

         

      Thanks.

        • 1. Re: i2c question
          laim.maskey

          Hi,

             

          The eeprom has two address bits set internally so that its address is always 0xA? with the ? supplied by the lower 3 address bit, so you can have 8 addresses starting at 0xA0.  The I2C device address is 7 bits wide with the 8th LSB indicating either an I2C Read (logic 1) or I2C Write (Logic 0). So you have only 7 bits in an I2C device address.

             

          i2cAddr = 0xA0 | ((value & 0x0007) << 1);

             

          What is happening in the code above is the value set by the user is bit masked with the 3 LSB to allow only valid address through. Next this value is shifted 1 location to the left so that it can be ORed bit for bit with the 7 bit base address..

             

          Sodafarl

          • 2. Re: i2c question
            moon.young.joo

            I See, Thanks, a lot.