This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Writing to Image Sensor over I2C

Well, we have gotten the address figured out and know what needs to be written to the I2C addresses for the image sensor. The problem is, the subaddresses are all 2 bytes instead of 1 like shown in the documentation for the I2C bus for the DM6467 and even then, after you try and write a byte to the device the I2C process enters the timeout loop. We have just modified the Spectrum Digital 480i passthrough code to do this and we seem to get to being able to write over I2C, but it times out. If you want I can provide the code that was modified to work.

  • Hi Richard,

    Can you clarify certain points?

    1. What is the problem if subaddresses are of 2 bytes?

    2. At what frequency are you operating the I2C bus?

    3. ALso post the modified code.

    Regards,

    Sid

  • Posting a snippet of your code would certainly help narrow down the problem.  Also, is this code in user space or kernel space?

  • The code we have modified is the code that was provided by Spectrum Digital on their website. All we have done is to remove the inputs from the composite video port and use the RAW input from the image sensor on the VPIF. I will post up the code to the OV5633.c and OV5633.h files and a snippet of the code from the OV5633_setup.c file.

    OV5633.c:

    #include "OV5633.h"
    #include "davincihd_i2c.h"
    #include "davincihd_i2c_gpio.h"
    #include "stdio.h"


    Int16 OV5633_rset( Uint16 id, Uint8 reg, Uint8 reg_value1, Uint8 reg_value2 )
    {
        Int16 errors = 0;
        Uint8 addr;
        Uint8 cmd[3];

        addr   = id;
        cmd[0] = reg;
        cmd[1] = reg_value1;
        cmd[2] = reg_value2;

        errors |= DAVINCIHD_I2C_write( addr, cmd, 3 );

        return errors;
    }

     

    OV5633.h:

    #ifndef OV5633_H_
    #define OV5633_H_

    #ifdef __cplusplus
    extern "C" {
    #endif

    #include "davincihd_i2c.h"
    #include "davincihd_i2c_gpio.h"

    /* ------------------------------------------------------------------------ *
     *  I2C Address                                                             *
     * ------------------------------------------------------------------------ */
    #define OV5633_I2C_ADDR_WRITE    (0x6c)
    #define OV5633_I2C_ADDR_READ     (0x6d)

    //Function Prototypes
    Int16 OV5633_setup( );

    #ifdef __cplusplus
    }
    #endif
         
    #endif /*OV5633_H_*/

    OV5633_setup.c:

    #include "OV5633.h"

    Int16 OV5633_setup()
    {
        Int16 errors = 0;


        errors |= OV5633_rset( OV5633_I2C_ADDR_WRITE, 0x30, 0x12, 0x80 );
        errors |= OV5633_rset( OV5633_I2C_ADDR_WRITE, 0x30, 0xfa, 0x00 );
        errors |= OV5633_rset( OV5633_I2C_ADDR_WRITE, 0x30, 0x0f, 0x00 );

        return errors;
    }

     

    That is only a small bit of the OV5633_ setup code but all it is is repeating liek that setting up the registers.

     

  • The spectrum digital codo does not rely on any operating system and it is meant to be run under CCS; is this your environment?  For example, this will not work under Linux environment; therefore you need to make sure Linux is not running when running code based of Spectrum Digital (SD).  Furthermore, this SD code is not supported.

    SD code was meant for board level tests to ensure major hardware interfaces work; if you want to spend time getting this to work, you certainly can, but you may have to add much of the support for VPFE.  Furthermore, when you move towards a more production-ready system which includes an OS such as Linux, much of the code you develop based on SD examples will likely be throw away code.  Under Linux, our video drivers are much more robust and feature complete and many of our platforms have support for micron sensors.  I can certainly undestand how a more complete os-based system can seem overwhelming but the work you do here to inplement ov5633 support will likely be re-used in the final product.

  • Ok, thank you for your help. We were figuring that we could port some of this code over to Linux and that's why we started in CCS using the SD examples as they seemed easier to work with, however that seems to have been an error on our part then. The Linux side is very daunting to us as our entire team is composed of Electrical Engineers, we do not have any programmers so that has been really holding us back. The project is coming to the end for the summer however so I will not have time to try and implement the coding in Linux. Thanks for all of your help however.

  • can you post the "OV5633.c and OV5633.h files and a snippet of the code from the OV5633_setup.c file. " ?