Forum: µC & Digital Electronics i2c strange behavior on lpc2148

von Gossamer (Guest)

Rate this post
0 useful
not useful
I'm having difficulties with setting up the i2c communication between uC 
and 3 sensors.
What im experiencing is following:
I'm able to receive one byte from sensors and the value is correct. 
Sensors are SRF10 and CMPS03. SRF10 has register 01 which always returns 
value 0x80 and register 00 which returns revision number. For both 
registers i receive correct values. I have tested reading the values in 
the loop to see if i always get the same value and that also works.

Sending the request to do measurement and reading the values fails.
When i try to read registers 02 and 03, which represents the 16bit 
value, reading the first register is ok but next one fails with error 
And that puzzles me. How come reading the one value works, reading it 
several times in a loop works, but reading values from one register and 
then from the other register, fails.

Sensor is good. Verified it on AVR setup where i2c is working :-)

Reading communication is done like this:
send start
-send address
-send register
send restart
-send address+R
-read register
send stop

Writing is done:
send start
-send address
-send data
-send data
send stop
What should i take a look at ?


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.