i2c strange behavior on lpc2148

Guest #3064331
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 
0x20.
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:
1
send start
2
-send address
3
-send register
4
send restart
5
-send address+R
6
-read register
7
send stop

Writing is done:
1
send start
2
-send address
3
-send data
4
-send data
5
send stop
What should i take a look at ?

Reply

A question of your own? This thread is over 13 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.