I'm trying to interface this I2C LCD (http://www.newhavendisplay.com/specs/NHD-C0216CiZ-FSW-FBW-3V3.pdf) with the Arduino. I'm pretty sure I have all the wiring hooked up correctly (including a mosfet based level conversion) from looking at the waveforms on a scope.
Here is some initialization code I got from a library by Francisco (had to modify a few things for my LCD).
Wire.begin(); Wire.beginTransmission ( _i2cAddress ); Wire.write ( (byte)0x0 ); // Send command to the display Wire.write ( FUNC_SET_TBL0 ); delay (10); Wire.write ( FUNC_SET_TBL1 ); delay (10); Wire.write ( 0x14 ); // Set BIAS - 1/5 Wire.write ( 0x78 ); // Set contrast low byte Wire.write ( 0x5E ); // ICON disp on, Booster on, Contrast high byte Wire.write ( 0x6D ); // Follower circuit (internal), amp ratio (6) Wire.write ( 0x0C ); // Display on Wire.write ( 0x01 ); // Clear display Wire.write ( 0x06 ); // Entry mode set - increment delay(10); _status = Wire.endTransmission (); Serial.println(_status);
If I look at the waveform with a logic analyzer I'm getting a valid ACK from the LCD for the slave address byte. Here's that image: http://www.glacialwanderer.com/_blog/blog2012/April/i2c_debug.png
I have tried putting in the wrong slave address and then I get the NAK. So it really seems like the LCD is sending the ACK back. Basically this looks good to me, but everything after this slave address byte and ack is broken. In the code above I'm writing a lot more bytes and none of that shows up on the waveform. Also the _status that I'm printing out in the code is 2 (failure from address NAK). So for some reason it seems that the Arduino is failing to send the bytes after the intial address and I don't know why. Does anyone have any ideas on what is going wrong?