Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > EZUSB I2C on cmos camera

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



EZUSB I2C on cmos camera
Moderator:
RSKV

Post Reply
Follow this topic



EZUSB I2C on cmos camera

giginjose posted on 25 Jul 2012 7:01 AM PST
Top Contributor
36 Forum Posts

 

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

 




Re: EZUSB I2C on cmos camera

aasi posted on 25 Jul 2012 09:57 PM PST
Cypress Employee
1090 Forum Posts

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? 



Re: EZUSB I2C on cmos camera

giginjose posted on 26 Jul 2012 12:03 AM PST
Top Contributor
36 Forum Posts

 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



Re: EZUSB I2C on cmos camera

Gayathri posted on 26 Jul 2012 04:20 AM PST
Cypress Employee
428 Forum Posts

 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



Re: EZUSB I2C on cmos camera

giginjose posted on 26 Jul 2012 06:50 AM PST
Top Contributor
36 Forum Posts

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

How can I acheive this ? 

 

Thank You



Re: EZUSB I2C on cmos camera

giginjose posted on 26 Jul 2012 07:15 AM PST
Top Contributor
36 Forum Posts

 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



Re: EZUSB I2C on cmos camera

aasi posted on 26 Jul 2012 09:17 AM PST
Cypress Employee
1090 Forum Posts

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



Re: EZUSB I2C on cmos camera

giginjose posted on 30 Jul 2012 03:40 AM PST
Top Contributor
36 Forum Posts

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



Re: EZUSB I2C on cmos camera

Bob Marlowe posted on 30 Jul 2012 03:57 AM PST
Top Contributor
1768 Forum Posts

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



Re: EZUSB I2C on cmos camera

aasi posted on 30 Jul 2012 05:11 AM PST
Cypress Employee
1090 Forum Posts

Please post the part number of the camera sensor as well 



Re: EZUSB I2C on cmos camera

giginjose posted on 30 Jul 2012 05:20 AM PST
Top Contributor
36 Forum Posts

 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



Re: EZUSB I2C on cmos camera

aasi posted on 30 Jul 2012 07:38 AM PST
Cypress Employee
1090 Forum Posts

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



Re: EZUSB I2C on cmos camera

giginjose posted on 31 Jul 2012 07:49 AM PST
Top Contributor
36 Forum Posts

 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

 

 



Re: EZUSB I2C on cmos camera

Bob Marlowe posted on 31 Jul 2012 08:49 AM PST
Top Contributor
1768 Forum Posts

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



Re: EZUSB I2C on cmos camera

giginjose posted on 01 Aug 2012 10:38 PM PST
Top Contributor
36 Forum Posts

 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. 

 






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