EmbDev.net

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


von Gossamer (Guest)


Rate this post
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 
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 ?

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.