Is it pure coincidence that all the upper nibbles are $4?
Is it pure coincidence that all the upper nibbles are $4?
Steve Earl www.datageo.co.uk
I believe this may be my first post to this forum...
Has anyone figured more of this out? I finally got my I2C serial adapter for the 1602 LCD to do something at least.
It was indeed very helpful to see the original code posted. Somehow my default address is $40.
When I use the code provided, I do get the display to light up and display "HELLO RCG! but when I try to change the initials to DHD, using the hex codes for D = $44, H=$48, and D=$44, I get THD in the display.
I am also looking for a bit more help with the control characters, and why the LCDWRITE routine needs 3 i2cwrite commands.
Thanks from noob Dave
There is information here.
http://www.picbasic.co.uk/forum/showthread.php?t=19222
Steve Earl www.datageo.co.uk
and here if you have pbp3
http://support.melabs.com/threads/98...F8574-20x4-LCD
Great, thank you. Lots of information in those posts.
Hmm, I am still having difficulty with this even after reading the above referenced threads.
I am working with PBP 3.0.7.0 and a pic 12F629. I am able to get the code writen by norohs (above) to work but I am having difficulty figuring it all out so that I can modify it for my own use.
Basically, I'd like to send some data and or ascii from my 12F629 to my LCD1602 via the I2C "adapter".
Can someone give me a bit more guidance?
you might get something from this
http://support.melabs.com/threads/1075-I2C-to-LCD
or tell us more on what your trying to achieve and post your code (in code tags)
I also found this code written by norohs difficult to work out and eventually I decided that it works more by accident than design and that there has to be a better way of doing this. This is what I worked out.
The LCD works in four bit mode which makes every byte sent a four bit control nibble plus a nibble of data. To send a byte of data two bytes have to be sent consisting of a control nibble plus high data nibble then control nibble plus low data nibble.
To send "H" which is $48
requires two LCDWRITE instructions
LCD_CMD = $44
GOSUB LCDWRITE
LCD_CMD = $48
GOSUB LCDWRITE
In each instruction the first 4 after the $ sets the R/W bit to write and $48 is made up from the 4 and 8 in red.
and "D" would be
LCD_CMD = $44
GOSUB LCDWRITE
LCD_CMD = $44
GOSUB LCDWRITE
and to print "DHD" would be
LCD_CMD = $44
GOSUB LCDWRITE
LCD_CMD = $44
GOSUB LCDWRITE
LCD_CMD = $44
GOSUB LCDWRITE
LCD_CMD = $48
GOSUB LCDWRITE
LCD_CMD = $44
GOSUB LCDWRITE
LCD_CMD = $44
GOSUB LCDWRITE
Looking at the LCDWRITE
LCDWRITE:
I2CWRITE D,C,ADDR,[LCD_CMD]
E=1
I2CWRITE D,C,ADDR,[LCD_CMD]
E=0
I2CWRITE D,C,ADDR,[LCD_CMD]
RETURN
each command is sent three times with E=0 then E=1 then E=0 which I think is an error, the first line is not needed.
LCDWRITE:
E=1
I2CWRITE D,C,ADDR,[LCD_CMD]
E=0
I2CWRITE D,C,ADDR,[LCD_CMD]
RETURN
but you can test this.
Why send it twice? On the LCD with the E bit set to 1 the data is loaded into a buffer and E has to change from 1 to 0 for the data to be transferred to the screen which is why the second instruction is required.
I decided to look for a better solution as I was not totally confident that the above was correct.
Darrel Taylor came to the rescue here
http://support.melabs.com/threads/98...F8574-20x4-LCD
As you can see from this not all Arduino LCDs are wired the same. The control and data nibbles can be either data/control or control/data.
johncouture worked this out for us in the thread above.
Steve Earl www.datageo.co.uk
Bookmarks