14 Replies Latest reply on Aug 1, 2012 12:38 AM by gigin.jose

    EZUSB I2C on cmos camera

    gigin.jose

      Hi,

         

      I am working on Cypress usb high speed controller Cy7c68013A. I need to interface I2C lines with a I2C slave device (a cmos camera sensor). The example code for I2C read uses EZUSB_ReadI2C from EZUSB  library. 

         

      My cmos camera slave address is 0x60 and the device ID is present in the sub address 0x1D. Here is the sequence I implemeted to read the device ID in a linux based system. 

         

      1. i2c_start()

         

      2. i2c_write_byte(0x60)

         

      3. i2c_ack()

         

      4. i2c_write_byte(0x1D)

         

      5. i2c_ack()

         

      6. i2c_write_byte(0x61)

         

      7. i2c_ack()

         

      8. value = i2c_read_byte ()

         

      The variable value gives the device ID. How can I implement this sequence with a EZUSB library ? 

         

       

         

      Thank You

        • 1. Re: EZUSB I2C on cmos camera
          anand.srinivasan.asokan

          The source of ezusb.lib is available at C:\cypress/usb/target/lib you can modify it there to add your own custom function.

             

          But why do you want to do that? Why not put it as a function outside the library? 

          • 2. Re: EZUSB I2C on cmos camera
            gigin.jose

             I was trying to use EZUSB library functions to configure and I2C slave device (a cmos camera sensor). 

               

            Can I use EZUSB_ReadI2C and EZUSB_WriteI2C for working with slave devices other that EEPROM. ?

               

             

               

            Thank You

            • 3. Re: EZUSB I2C on cmos camera
              gayathri.vasudevan

               Hi,

                 

               

                 

              Yep. It will work for other Slave I2C devcies as well. Please refer Dev_IO example coming as part fo FX2LP DVK. That uses the same EZUSB_ReadI2C and EZUSB_WriteI2C functions for I2C Slave devcices at different address.

                 

               

                 

              Regards,

                 

              Gayathri

              • 4. Re: EZUSB I2C on cmos camera
                gigin.jose

                 I am trying to read from a slave device at address 0x60, with sub address 0x1D. 

                   

                How can I acheive this ? 

                   

                 

                   

                Thank You

                • 5. Re: EZUSB I2C on cmos camera
                  gigin.jose

                   I dont have an evaluation board at hand, but i tried the function EZUSB_ReadI2C(0x20,0x01,&button); 

                     

                  and probed the SDA and SCL lines on the scope. I found that the SDA lines have the values 0x41. This is due to the implementation I2DAT = (addr << 1) | 0x01; inside the function EZUSB_ReadI2C_. 

                     

                  why is the address left shifted by one. The 0x01 is orred for read, but what is the purpose of shifting by one. 

                     

                  Thank You

                  • 6. Re: EZUSB I2C on cmos camera
                    anand.srinivasan.asokan

                    Because the address is 7-bits and the 8th bit is to say whether it is a read transaction or a write transaction.

                    • 7. Re: EZUSB I2C on cmos camera
                      gigin.jose

                      How can I read the value of a register from cmos camera device with 7 bit slave address 0x21 and register address 0x00. 

                         

                      The EZUSB_ReadI2C doesnt have option to specify the register address (0x00 or any other addresses). How do we implement this with multiple read/write functionality ?

                         

                      Thank You

                      • 8. Re: EZUSB I2C on cmos camera
                        user_1377889

                        Have a look at the camera's datasheet: The mechanism usually is you first write the register address to a specified address (Datasheet) of your device (camera) and then you may read from your device the given data. Often with bulk-data devices you may read more than one register-value, check with camera's datasheet as well.

                           

                         

                           

                        Bob

                        • 9. Re: EZUSB I2C on cmos camera
                          anand.srinivasan.asokan

                          Please post the part number of the camera sensor as well 

                          • 10. Re: EZUSB I2C on cmos camera
                            gigin.jose

                             I am looking into the FX2 LP DVK schematics and code for better understanding of the I2C transfer to the EEPROM device. 

                               

                            The project I am refering is memtest. The function EZUSB_WaitForEEPROMWrite(LED_ADDR);is used, where LED_ADDR is defined as 0x21.I understatnd that 0x21 is the I2C expander (PCF8574T) address.

                               

                            How is the EEPROM accessed in FX2LP DVK.  

                               

                            As per the schematics, the EEPROM A1 and A2 is grounded and A0 is pulled high to 3.3V. 

                               

                            The basic EEPROM address is set as 1010 A2 A1 A0 . Hence the 7 bit EEPROM address becomes 51 (01010 A2 A1 A0) as per the hardware configuration, and we use A3 and A2 address for read/write operations respectively. 

                               

                            Is there any example code where read and write happens to I2C EEPROM using the above mentioed addresses ? Can I know how read and write happens to the EEPROM IC in the DVK. 

                               

                            Thank You

                            • 11. Re: EZUSB I2C on cmos camera
                              anand.srinivasan.asokan

                              Look at vend_ax example... specifically vendor request 0xA2 and 0xA9.

                              • 12. Re: EZUSB I2C on cmos camera
                                gigin.jose

                                 The camera sensor I use is omnivision OV9650. I am attaching the datasheet of the sensor module. 

                                   

                                The device mentioned has slave address 0x60 for write and ox61 for read. There are configuration regsiters inside the cmos camera sensor module for configuring the various parameters of the camera. How can I read/write to these register locations using EZ USB library. 

                                   

                                The sequence for a read operation on a linux based system is as follows:

                                   

                                 

                                   

                                1. i2c_start()

                                   

                                2. i2c_write_byte(0x60)

                                   

                                3. i2c_ack()

                                   

                                4. i2c_write_byte(0x1D)

                                   

                                5. i2c_ack()

                                   

                                6. i2c_write_byte(0x61)

                                   

                                7. i2c_ack()

                                   

                                8. (unsigned char) value = i2c_read_byte ()

                                   

                                 

                                   

                                How canI implement this similar sequence using EZ USB library. 

                                   

                                 

                                   

                                Thank You

                                • 13. Re: EZUSB I2C on cmos camera
                                  user_1377889

                                  Here http://www.ovt.com/download_document.php?type=document&DID=63  is the link to the SCCB-interface description which does not look like an I2C, more than a single-wire interface.

                                     

                                  Did I overlook something?

                                     

                                   

                                     

                                  Bob

                                  • 14. Re: EZUSB I2C on cmos camera
                                    gigin.jose

                                     As I understand, I am using the 2-wire interface of SCCB. Unlike the I2C, the 9th clock of SCCB is a don't care, whereas I2C uses the 9th bit for acknowledgment. The I2C protocol works fine with SCCB devices, but a pure SCCB protocol (without ack bit) may not work fine for I2C devices. 

                                       

                                    Hence, considering the omnivision device as a pure I2C slave would be fine.