need i2c help please

Started by b clapper May 23, 2005
Hi Everyone,

I'm having a problem with an i2c interface between LPC2138
and an image sensor. I'm using i2c to set parameters in
the image sensor, like exposure, rgb gain, clocking etc. After
capturing a frame, I'm trying to use i2c to get information
back from the sensor about the relative brightness of the
frame. I hope to use this to adjust my exposure setting.

Anyway, I'm able to write the parameters to the image sensor
without problems (I think) but I'm not having success reading.
I know I can set some parameters correctly because I can change
clocking, for example, and see it on the scope. Unfortunately,
I can only read a few parameters before I start seeing
unrecognizable settings.

I hooked my board to the scope and trapped the waveforms
on the SCL and SDA lines while reading and here's what I see. (By
the way, I have a tektronix tds1002 - and I'm not sure if this is
adequate to 'catch' everything I need).

- successful start condition.
- successful send of slave_address + R bit
- ack by receiver (camera in this instance)

Then, I see a blip on the sda line. It goes from low to high and
then pulled low again before the next SCL peak. I *think* this
is ok, but not sure. I think this is the LPC releasing SDA after
his ack, and the camera taking control of it to start sending
data.

Anyway, next I see the data coming. 8 bits, 1 ack bit, then the
blip. This might happen for another byte or two and then I see
8 data bits, and ack bit and then no 'blip'. At this point, the
SDA line goes high and stays high - until the lpc acks eight
high bits. All data from this point, of course, is 0xFF. It
doesn't happen in the same place but it always happens.
Sometimes I read 3-4 bytes, other times 1 or 2. I'm trying to
read 20.

It seems as if the camera has left the building and the LPC is
talking to himself! The image sensor is still running (I can
measure his pxlclock, vsync, hsync, etc).

Anyway, I'm not sure if I've got a configuration problem or a
timing problem or what. I've tried slowing down the i2c clock
from 400khz to 100khz, I tried using different values for the
duty cycles (SCLH/SCLL - not sure what that does if anything).
I've made sure that I2CON_AA is set after each read to ensure
I get an ack. I do that for all reads except the last one.

Is it possible for the camera to see a stop condition and not the
LPC?

Anyway does anyone have any ideas of what I might look for or try?
If not, do you know an i2c expert in Europe or the UK (the closer
to Zurich Switzerland better for me)?

Any pointers or consideration would be greatly appreciated.

thanks,
Bryan


An Engineer's Guide to the LPC2100 Series

Hi, Brian
I actually use the I2C interface on a LPC2138 to drive a
128x64 graphic display (you can see it on the photos folder)
The I2C works correctly for me. (clocked at 1 MHz)
Anyway you don't say how you drive the I2C interface.
I use an interrupt driven routine...
Anyway, when I tried to read the display status, I had to modify the
routine because the status i had founde were a bit different from how
the Datasheet explained.
I hope this can help.
Greetings.
D.Bertolino


Tuesday, May 24, 2005, 11:44:25 AM, you wrote:
> Hi, Brian
> I actually use the I2C interface on a LPC2138 to drive a
> 128x64 graphic display (you can see it on the photos folder)
> The I2C works correctly for me. (clocked at 1 MHz)
> Anyway you don't say how you drive the I2C interface.
> I use an interrupt driven routine...
> Anyway, when I tried to read the display status, I had to modify the
> routine because the status i had founde were a bit different from how
> the Datasheet explained.
> I hope this can help.
> Greetings.
> D.Bertolino
>

Hi D.,
Thanks for your note. I'm currently not using interrupts to drive
the i2c. I only have one device on the bus and didn't think it was
necessary. Do you think that's a problem?

In your setup do you use the same duty cycles for I2CSCLL/I2CSCLH?
or are they equal? Does it matter?

Anyway, thanks for your help.

Bryan.



--- In lpc2000@lpc2..., b clapper <clapper@b...> wrote:
> Hi D.,
> Thanks for your note. I'm currently not using interrupts to drive
> the i2c. I only have one device on the bus and didn't think it was
> necessary. Do you think that's a problem?
>
> In your setup do you use the same duty cycles for I2CSCLL/I2CSCLH?
> or are they equal? Does it matter?
>
> Anyway, thanks for your help.
>
> Bryan.

Hi Bryan,
I decided to use an Interrupt driven routine because I need to write
1KByte frame twice at second (the entire ldc field), and I can't wait
until the routine will end (I need to do other things in that time).
And the routine is very simple (perhaps more than the non interrupt
one)
In my setup I use the same value for I2CSCLL & I2CSCLH.
Anyway, I think it will not represent a problem if the 2 value
differing one from the other of a unit.
If you think that this is the problem try to put the same value (the
higher one for both) in the two register.
In any case, in my application, the lcd controller (ste2002) is
enabled to work at 1MHz, while the I2C is enabled to work at a max of
400KHz.
If you think it can help, I can post my I2C routine (in GCC)

Good luck
Davide Bertolino


> Thanks for your note. I'm currently not using interrupts to drive
> the i2c. I only have one device on the bus and didn't think it was
> necessary. Do you think that's a problem?

Not necessarily. I am using I2C without interrupts. However, due to
the error checking that still needs to be done, an interrupt driven
routine may actually be simpler than a non-interrupt driven routine.

Kind regards,
Thiadmer