I2C/TWI LCD1602
#1
Posted 26 January 2011 - 12:13 AM
I have the I2CBus code and now I need to work out how the I2C bus works before I can attempt to build a driver for the display module.
Looking for any suggestions about how I should tackle the problem.
Thanks,
#3
Posted 26 January 2011 - 12:24 PM
Thanks for the link.
I downloaded the zip file and was able to run the HelloWorld_I2C solution. Running as per the download didn't work, that is it just ran to completion and no display. So I then changed the address to 0x27 (as per the DFRobot) and at that point it threw an exception in the I2CBus WriteRead function included below.
public void WriteRead(I2CDevice.Configuration Config, byte[] WriteBuffer, byte[] ReadBuffer, int TimeOut) { ThrowIfDisposed(); lock(this.Device) { this.Device.Config = Config; I2CDevice.I2CTransaction[] xacts = new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(WriteBuffer), I2CDevice.CreateReadTransaction(ReadBuffer) }; // I2CDevice.Execute returns the total number of bytes // transfered in BOTH directions for all transactions int byteCount = this.Device.Execute(xacts, TimeOut); if(byteCount < (WriteBuffer.Length + ReadBuffer.Length)) throw new System.IO.IOException(); } }
I am well and truly out of my comfort zone with this, it is very low level and I just don't have the wherewithall to understand this at present.
Looking at the local variables I can see that bytecount is 1 and the length of the WriteBuffer and ReadBuffer is 1 each so a total of 2, which is why it throws the exception. I have no idea as to what is really going on.
Before somebody suggest it, I have put pull-up resistors on the I2C bus (4k7).
Any further suggestions greatly appreciated (including suitable books as I am new to C#, .NET and uC).
Thanks
#4
Posted 09 July 2011 - 09:36 AM
#5
Posted 13 July 2011 - 01:20 PM
#6
Posted 19 June 2012 - 01:34 PM
Thanks for the link.
I downloaded the zip file and was able to run the HelloWorld_I2C solution. Running as per the download didn't work, that is it just ran to completion and no display. So I then changed the address to 0x27 (as per the DFRobot) and at that point it threw an exception in the I2CBus WriteRead function included below.
public void WriteRead(I2CDevice.Configuration Config, byte[] WriteBuffer, byte[] ReadBuffer, int TimeOut) { ThrowIfDisposed(); lock(this.Device) { this.Device.Config = Config; I2CDevice.I2CTransaction[] xacts = new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(WriteBuffer), I2CDevice.CreateReadTransaction(ReadBuffer) }; // I2CDevice.Execute returns the total number of bytes // transfered in BOTH directions for all transactions int byteCount = this.Device.Execute(xacts, TimeOut); if(byteCount < (WriteBuffer.Length + ReadBuffer.Length)) throw new System.IO.IOException(); } }
I am well and truly out of my comfort zone with this, it is very low level and I just don't have the wherewithall to understand this at present.
Looking at the local variables I can see that bytecount is 1 and the length of the WriteBuffer and ReadBuffer is 1 each so a total of 2, which is why it throws the exception. I have no idea as to what is really going on.
Before somebody suggest it, I have put pull-up resistors on the I2C bus (4k7).
Any further suggestions greatly appreciated (including suitable books as I am new to C#, .NET and uC).
Thanks
Did you ever get this to work?
#7
Posted 19 June 2012 - 01:35 PM
Where did you change the address?Just a followup, I solved my problem (same as the original poster) by including 4.7k pull-up resistors on sca and scl. Or, more to the point, wiring them in correctly.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users