Hello,
I'm trying to talk to the MPR084 using my Arduino Duemilanove. I've got the level shifting figured out (I believe), but I'm not getting any response from the MPR084. I have tried 2 of the chips with the same results.
Part of my problem is that I don't really understand exactly what the TWI subroutines do. That is, where is the 1:1 correspondence between the TWI commands and the i2c communication? When does the data start flowing during a write? How about during a read? The abstraction (Wire library) of the physical underlying process (i2c data stream) is not well documented, and I am having trouble gluing them together.
For example, one of the first Google hits for examples is http://www.neufeld.newton.ks.us/electronics/?p=241. When reading i2c data, he recommends doing
// Send input register address
Wire.beginTransmission(address); Wire.send(REGISTER_INPUT); Wire.endTransmission();
// Connect to device and request two bytes
Wire.beginTransmission(address); Wire.requestFrom(address, 2); // 2 bytes.
if (Wire.available()) { data = Wire.receive(); } ; Wire.endTransmission();
...Because the documentation for his device shows that in order to read his chip, it requires: Slave Address, then Command Byte, then Slave Address again, then the Arduino receives the data bytes as specified.
But for the MPR084, to read it you do: Slave Address, then Command Byte, then receive the n data bytes.
I notice that the Wire.requestFrom() function actually requires the address as one of its arguments, but I don't think I want to do that again because it's not part of the data flow as specified by the MPR084. What I think I need to do is something roughly like:
beginTransmission(address); endTransmission(address); //without sending any data...
receiveFrom(REGISTER_INPUT, 1); // to receive 1 byte from the register I'm interested in
store=receive();
...but I've tried it and it didn't work. Any suggestions would be appreciated. Thanks for any help.
-Mike Schwager