2009-04-03 14:39:05 uClinux bf537- twi_test.c for OV7660 camera
Ashutosh natraj (UNITED KINGDOM)
Message: 72137
Hi All,
I have been working on the OV7660 camera on the BF537E board, and thus wanted to read the
camera device ID, from the datasheet of camera it can be seen the register address 0x0a , 0x0b have the MSB and LSB (7660)of the camera device id. thus to read the device id I was looking into the twi_test.c program in the uClinux distribution. can be found in the folder ashu@ashu:~/uClinux-dist-2008R1.5-RC3/user/blkfin-test/twi_test
after changing the code to read the value from reg addr 0x0a I get still the error upon running, though I supply the correct slave address: 0x42,
The error I get is:
root:~> ./twi_test 0x42 0x09
slave addr: 0x42
Case 1: Program with correct I2C_SLAVE address
-----------------------------------------
local_cam_get_register: error sending register address 0x0a, errno = 1
Fail to get data from register 10
So I was looking into the code where the cam gets the register values.
========================================================
int
local_cam_get_register(int filehandle,
int bus_width,
int reg_addr,
int *val)
{
printf("reg_add: %d\n", reg_addr);
unsigned char regval = reg_addr; /* Device register to access */
unsigned char buf[10];
int try_count;
buf[0] = regval;
if ( write(filehandle, buf, 1) != 1) // accordingly the write function write(int fd,char *buf, int num bytes) but i change 1 by the "sizeof(buf)" still I get the error.
{
printf("local_cam_get_register: error sending register address 0x%02x, errno = %d\r\n",
regval, errno);
return -1;
}
if (read(filehandle, buf, bus_width) == bus_width)
{
if (bus_width == 1)
{
*val = buf[0];
}
else
{
*val = buf[0] << 8;
*val |= buf[1];
}
return 0;
}
==========================================================
practically it should have read the value stored in the register address 0x0a and 0x0b, by entering the next if loop read(filehandle, buf, bus_width)==bus_width)
please let me know more about this.
I have attached my twi_test.c file as well for faster and easier understanding of my problem.
but probably you need to have the set up for the same.
thanks in advance.
Ashu
Replicators project
SHU, UK
twi_test.c
QuoteReplyEditDelete
2009-04-06 00:30:15 Re: uClinux bf537- twi_test.c for OV7660 camera
Mike Frysinger (UNITED STATES)
Message: 72193
use the i2c-tools package instead. it's much easier to scan the i2c bus and read/write device registers with that. it's all command line driven and requires no code changes.
QuoteReplyEditDelete
2009-04-07 07:51:30 Re: uClinux bf537- twi_test.c for OV7660 camera
Ashutosh natraj (UNITED KINGDOM)
Message: 72324
Dear Mike,
Thanks for your help, I installed the tools. according to the README file says it creates a Manual upon
installation, but I couldn't find one to use the tool to read the registers from the camera device. Could
you please let me how can I use this tool more effectively, as it says it is command line driven tool.
Also as I'm using the blackfin i have restricted memory of 4MB in total.please help
thanks in advance
Ashutosh Natraj
QuoteReplyEditDelete
2009-04-09 05:22:01 Re: uClinux bf537- twi_test.c for OV7660 camera
Mike Frysinger (UNITED STATES)
Message: 72458
the README assumes you're installing the programs on your host system. you're using the uclinux distribution here, so that wouldnt make sense.
the source tree for i2c-tools is pretty small so it's fairly trivial to locate the manuals. they're in the tools/ directory right next to each binary.