2009-05-26 03:28:17     Twi problems with OV7660 Cmos sensor and PPI with BF561

Document created by Aaronwu Employee on Aug 23, 2013
Version 1Show Document
  • View in full screen mode

2009-05-26 03:28:17     Twi problems with OV7660 Cmos sensor and PPI with BF561

xabi romero (UNITED STATES)

Message: 74571   

 

Hi to everybody.

 

I am trying to configure the OV7660 cmos sensor to ITU656, but when i write the new register values, and then i read it, the value doesn´t change.

 

I am working with the CM-BF561 V2 and DEV-Board V2 from Bluetechnix, and the source code is (see attached file):

 

    int file;

    if ((file = open("/dev/i2c-0", O_RDWR )) < 0) {

        /* ERROR HANDLING; you can check errno to see what went wrong */

        printf("Cannot open Adapter");

        //exit(1);

    }

   

    int addr = 0x21; /* The OV7660 device slave addresses are 42 for write and 43 for read, we shift right one bit anyway */

    if (ioctl(file,I2C_SLAVE,addr) < 0) {

        //ERROR HANDLING; you can check errno to see what went wrong

        printf("ioctl does not work\n");

        //exit(1);

    }

 

// El primer parámetro

    __u8 reg = 0x0A; /* I try to read a value from 0x0A */

    __s32 res;

 

     res = i2c_smbus_read_byte_data(file,reg);

   //close(file);

    if (res < 0) {

        printf("SMBUS read ERROR %d\n",res);

        // ERROR HANDLING: i2c transaction failed

    } else {

       printf("Result: PID (0x0A) = %x\n",res);

    /* res contains the read word */

    }

 

// El segundo parámetro

    reg = 0x0B; /* I try to read a value from 0x0A */

 

 

     res = i2c_smbus_read_byte_data(file,reg);

    //close(file);

    if (res < 0) {

        printf("SMBUS read ERROR %d\n",res);

        // ERROR HANDLING: i2c transaction failed

    } else {

       printf("Result: VER (0x0B) =  %x\n",res);

    /* res contains the read word */

    }

// El tercer parámetro

   reg = 0x1C; /* I try to read a value from 0x0B */

 

     res = i2c_smbus_read_byte_data(file,reg);

   // close(file);

    if (res < 0) {

        printf("SMBUS read ERROR %d\n",res);

        // ERROR HANDLING: i2c transaction failed

    } else {

       printf("Result: MIDH (0x1C) =  %x\n",res);

    /* res contains the read word */

    }

// El cuarto parámetro

   reg = 0x1D; /* I try to read a value from 0x0B */

 

     res = i2c_smbus_read_byte_data(file,reg);

   // close(file);

    if (res < 0) {

        printf("SMBUS read ERROR %d\n",res);

        // ERROR HANDLING: i2c transaction failed

    } else {

       printf("Result: MIDL (0x1D) =  %x\n",res);

    /* res contains the read word */

    }

// El quinto parámetro

   reg = 0x13; /* I try to read a value from 0x0B */

 

     res = i2c_smbus_read_byte_data(file,reg);

  //  close(file);

    if (res < 0) {

        printf("SMBUS read ERROR %d\n",res);

        // ERROR HANDLING: i2c transaction failed

    } else {

       printf("Result:     COM8 (0x13) =  %x\n",res);

    /* res contains the read word */

    }

 

 

res = i2c_smbus_write_byte_data(file,reg,0x00);

 

      if (res < 0) {

            printf("SMBUS read ERROR %d\n",res);

            // ERROR HANDLING: i2c transaction failed

        } else {

       printf("Result:     COM8 (0x13) =  %x\n",res);

    /* res contains the read word */

    }

// El sexto parámetro

 

     res = i2c_smbus_read_byte_data(file,reg);

   // close(file);

    if (res < 0) {

        printf("SMBUS read ERROR %d\n",res);

        // ERROR HANDLING: i2c transaction failed

    } else {

       printf("Result:     COM8 (0x13) =  %x\n",res);

    /* res contains the read word */

    }

 

close(file);

 

 

And i have another problem with the ppi driver; I am using the PPI1 with the Hitachi TFT displya and i wanto to use the PPI0 with the cmos sensor. I have changed the bfin_ppi.c file, because the BF-561 is not supported, but i don´t know if i do it OK.

 

In the device.txt table, i have attached the /dev/ppi node with the major number 241, and so on.

 

I have attached the bfin_ppi.c file.

 

thanks to everybody.

 

 

 

Regards

 

ov7660.c

bfin_ppi.c

QuoteReplyEditDelete

 

 

2009-05-26 03:38:31     Re: Twi problems with OV7660 Cmos sensor and PPI with BF561

Mike Frysinger (UNITED STATES)

Message: 74573   

 

try using the i2c-tools package in the uclinux-dist to dump and read/write the registers

QuoteReplyEditDelete

 

 

2009-05-26 05:18:54     Re: Twi problems with OV7660 Cmos sensor and PPI with BF561

xabi romero (UNITED STATES)

Message: 74598   

 

Hi Mike.

 

i have use the i2ctools, but is impossible to write the new register value. Why do i have to put the device number 0x21 if the number is 42?

 

The OV7660 device slave addresses are 43 for write and 42 for read, we shift right one bit anyway. Why we have to shift right one bit? How do i put the 0x43 slave address?

 

i2cset 0 33 0x13 0x00

No size specified (using byte-data access)

WARNING! This program can confuse your I2C bus, cause data loss and worse!

I will write to device file /dev/i2c-0, chip address 0x21, data address

0x13, data 0x00, mode byte.

Continue? [Y/n] y

Warning - data mismatch - wrote 0x00, read back 0xa1

QuoteReplyEditDelete

 

 

2009-05-26 05:23:12     Re: Twi problems with OV7660 Cmos sensor and PPI with BF561

Mike Frysinger (UNITED STATES)

Message: 74599   

 

the address is not 42/43.  i2c addresses are 7-bits, not 8-bits.  please read the documentation:

  docs.blackfin.uclinux.org/doku.php?id=i2c

Attachments

Outcomes