You know what it’s like. New device that you want to work with because someone said it would be easy and used fewer I/O lines. Well, that’s me right now. I have a new I2C LCD that just arrived from Farnell (http://uk.farnell.com/midas/mccog21605d6w-sptlyi/lcd-cog-2x16-stn-grn-b-l-i2c/dp/2063205?Ntt=2063205) Pretty cheap and there seems to be some documentation available (http://www.farnell.com/datasheets/1485481.pdf).
Now not only is this my first I2C LCD project, but it’s my first time with anything I2C. I’m using my Spider and have connected an extender to port 4 (IKU X). I’ve brought out pins 8 (SDA) and 9 (SCK) according to the Spider Schematic (http://www.ghielectronics.com/downloads/schematic/FEZ_Spider_Mainboard_SCH.PDF). The docs say that LCD has an I2C address of 0111110b, which when right shifted becomes 01111100b (0x7C). SO I setup my I2C like this
I2CConfig = new I2CDevice.Configuration(0x7c, 100);
I2C = new I2CDevice(I2CConfig);
So, first question, how do I know that this is using I2C_1 on the Spider (Port 4) and not I2C_2 (Port 10)?
And then I want to initialise the device, send it some text, etc. So I create a function to follow the initialise routine on page 9 of the manual for 3v3 operation, throwing some sleeps in for good measure:
var xActions = new I2CDevice.I2CTransaction[1];
xActions[0] = I2CDevice.CreateWriteTransaction(new byte[] { 0x0, 0x38 });
I2C.Execute(xActions, 1000);
Thread.Sleep(100);
xActions[0] = I2CDevice.CreateWriteTransaction(new byte[] { 0x0, 0x39 });
I2C.Execute(xActions, 1000);
Thread.Sleep(100);
xActions[0] = I2CDevice.CreateWriteTransaction(new byte[] { 0x0, 0x14 });
I2C.Execute(xActions, 1000);
Thread.Sleep(100);
xActions[0] = I2CDevice.CreateWriteTransaction(new byte[] { 0x0, 0x74 });
I2C.Execute(xActions, 1000);
Thread.Sleep(100);
xActions[0] = I2CDevice.CreateWriteTransaction(new byte[] { 0x0, 0x54 });
I2C.Execute(xActions, 1000);
Thread.Sleep(100);
xActions[0] = I2CDevice.CreateWriteTransaction(new byte[] { 0x0, 0x6F });
I2C.Execute(xActions, 1000);
Thread.Sleep(100);
xActions[0] = I2CDevice.CreateWriteTransaction(new byte[] { 0x0, 0x0C });
I2C.Execute(xActions, 1000);
Thread.Sleep(100);
xActions[0] = I2CDevice.CreateWriteTransaction(new byte[] { 0x0, 0x01 });
I2C.Execute(xActions, 1000);
Thread.Sleep(100);
And I get nothing, no blinking cursor or anything.
I try to send it some text
public void Write(string sText)
{
var xActions = new I2CDevice.I2CTransaction[1];
byte[] buf = Encoding.UTF8.GetBytes(sText); // Convert the string to array
xActions[0] = I2CDevice.CreateWriteTransaction(buf);
I2C.Execute(xActions, 1000);
}
and still nothing.
So is it my hardware, is it my software? How will I ever find out?
Has anyone any experience of addressing I2C LCD devices, ideally the Midas devices? Or what about I2C experience that can point me in the right direction to help get this sorted out?
Thanks in advance.