OV7725 / OV5642 no response over I2C Topic is solved

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

Pethead
Posts: 37
Joined: Mon Jul 11, 2016 1:47 pm
Has thanked: 1 time

OV7725 / OV5642 no response over I2C

Postby Pethead » Thu Feb 16, 2017 4:34 pm

Hello there,

I have been trying to get my camera modules working for a few days now without any success. None of my two camera modules doesn't seem to respond to anything over I2C which leads me to believe that they are broken, and that would be quite weird since they are new...

I have the camera modules OV5642 module, (OV5642 datasheet) and the camera module OV7725 datasheet (I haven't found any PIN out for the OV7725 since they aren't printed on the board so I've just assumed that they are the same as the ones given in the OV5642 module, which might be wrong)

Code: Select all

#define OV7725_WRITE_ADDR   0x42
#define OV7725_READ_ADDR   0x43

#define BLUE_REG         0x01

static unsigned char rxbuf[10];
static unsigned char txbuf[10];

/* I2C1 interface */
static const I2CConfig i2ccfg1 = {
      OPMODE_I2C,
      100000,
      STD_DUTY_CYCLE,
};
void ov7725_Init(void)
{
   msg_t status;

   i2cStart(&I2CD1, &i2ccfg1);

   txbuf[0] = BLUE_REG;

   i2cAcquireBus(&I2CD1);
   status = i2cMasterTransmit(&I2CD1, OV7725_READ_ADDR, txbuf, 1, rxbuf, 1);
   i2cReleaseBus(&I2CD1);

   if (rxbuf[0] == 0x80)
      for(;;); /* Received default blue register data */
}


The status returned from i2cMasterTransmit is always MSG_RESET (-2) and I don't know how what the problem might be

The I2C is working as I can see the data and clock signal working as the attached pictures are showing. I've tried lowering the I2C clock speed to 100 KHz instead of 400 KHz and I've attached pull-up resistors on both lines.

I've also attached an external clock of 17MHz that is generated from Timer1 / PWM to the modules but that didn't seem to help at all since I don't really think it's needed to begin with.

I haven't really bothered with the DCMI interface yet since I am not even getting any response from the devices over I2C.

(Ofcourse when I've tried the ov5642 I've used the slave address specified in that datasheet and the register addresses / default values)..

Any suggestions what might be wrong?
Attachments
I2C_SDA.jpg
I2C SDA
I2C_SCK.jpg
I2C SCK

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: OV7725 / OV5642 no response over I2C

Postby Giovanni » Thu Feb 16, 2017 4:51 pm

Hi,

Addresses must be passed without LSb (rw bit), have you verified this?

Also look at this guide: http://wiki.chibios.org/dokuwiki/doku.p ... e_shooting

Giovanni

Pethead
Posts: 37
Joined: Mon Jul 11, 2016 1:47 pm
Has thanked: 1 time

Re: OV7725 / OV5642 no response over I2C

Postby Pethead » Fri Feb 17, 2017 8:13 am

Yes I've tried with and without the rw bit,

Code: Select all

#define OV7725_WRITE_ADDR   0x42
#define OV7725_READ_ADDR   0x43
So the slave address of the device would be the 0x42

I've also tried by setting the pins in the code

Code: Select all

palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN);   /* SCL */
palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN);   /* SDA */

But the result remain the same, I've also tried adding a 4.7k external pull up resistors on both the SCK and SDA lines.

I've done this on both the chips and nothing seems to work, however from the ov5642 chip I can see some activity on the output from the chip, for example see attached picture of HREF pin.

HREF - output (Active High: Line/Data Valid; indicates active pixels)
Attachments
HREF.jpg
pinconfig.png
I2C pin configuration

Pethead
Posts: 37
Joined: Mon Jul 11, 2016 1:47 pm
Has thanked: 1 time

Re: OV7725 / OV5642 no response over I2C

Postby Pethead » Fri Feb 17, 2017 9:41 am

On my EasyMX Pro V7 board there is also a 24AA01 EEPROM chip connected to ic2_1 but o n the pins PB6 and PB7 instead, and I can't seem to get that to work either, which strongly leads me to believe that I am doing something wrong...

Now I am trying to get some kind of response from the EEPROM chip. The SCK and SCL lines have 2k external pull up resistors on them and the A0 is connected to VCC while the A1 and A2 pins of the EEPROM chip is connected to ground, I would assume that this has to do with addressing if you have multiple EEPROM chips. However, the datasheet states that they are not connected.

The address of the device is 1010 XXX(R/W) and I've tried addressing it with 0xA8, 0xA4, 0xA2 and 0xA0 (since one of the pins is set to Vcc and the two others to ground)

I've looked at the SDA line with the four different addresses and they all look the same for some reason, it appears as if the lower nibble of the address is has no effect..
Attachments
A0.jpg
Address A0
A2.png
Address A2
A4.jpg
Address A4

Pethead
Posts: 37
Joined: Mon Jul 11, 2016 1:47 pm
Has thanked: 1 time

Re: OV7725 / OV5642 no response over I2C

Postby Pethead » Fri Feb 17, 2017 10:04 am

The reason why the lower 4 bits of the address didn't matter was because the EEPROM chip started sending on the SDA line as soon as it received 1010 and I had to do another write sequence to the chip. So the I2C bus is working however I can't manage to communicate with the camera modules.

steved
Posts: 823
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: OV7725 / OV5642 no response over I2C

Postby steved » Fri Feb 17, 2017 10:45 am

Pethead wrote:The reason why the lower 4 bits of the address didn't matter was because the EEPROM chip started sending on the SDA line as soon as it received 1010 and I had to do another write sequence to the chip.

That doesn't sound right - even if part of the address is "don't care", I'm sure the I2C spec says that comms is based on 9-bit sequences (8 data from the transmitter, then an acknowledge bit from the receiver), and thus an addressed device doesn't respond until it's received and acknowledged the full address packet.

The ChibiOs I2C routines expect addresses in the range 0x01..0x7e or thereabouts (i.e. shift an 8-bit 'address' right one bit to strip out the R/W bit), so your use of any address >0x7e is an error (unless you've got 10-bit addressing enabled, but that isn't fully supported, IIRC)

Pethead
Posts: 37
Joined: Mon Jul 11, 2016 1:47 pm
Has thanked: 1 time

Re: OV7725 / OV5642 no response over I2C

Postby Pethead » Fri Feb 17, 2017 11:40 am

Thank you for the response, you are completely right, my mistake. I had to re-check and I shifted the address of the EEPROM chip 1 bit to the right A0 -> 50 and it started communicating and sends all number of bytes that I specify.

For the OV5642 chip the address should then be 0x78 -> 0x3C, when I try to send this address it still just transmit the address and don't send the other stuff that is in the transmit buffer.

For the OV7725 chip the address should then be 0x42 -> 0x21, same as above, just the address is being sent even though that I tell it to send more. So I guess I'm not receiving an ACK from the chip.

Pethead
Posts: 37
Joined: Mon Jul 11, 2016 1:47 pm
Has thanked: 1 time

Re: OV7725 / OV5642 no response over I2C  Topic is solved

Postby Pethead » Fri Feb 17, 2017 3:02 pm

... Apparently the bags were mislabelled, so I was trying address ov5642 with the address for ov7725 and the other way around...


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 17 guests