Mike Goelzer wrote: > I have a snippet of code here which is from a Parallax app note on > interfacing a PIC to a standard character LCD module. It is very > sparsely commented, and basically I was wondering if someone could > help me figure out how it works. Here's the code: > > mov temp2,#00110000b > ;Initialize LCD: set 8-bit, > 1-line ;operation > > call blip_E > mov temp2,#00001110b > call blip_E > mov temp2,#00000110b > call blip_E > > Can someone explain to me what each of those three instructions > which are being sent to the LCD are doing? I'm actually working > with a 2-line LCD, and I therefore want to know which of those 3 > instructions is setting the LCD to singe-line mode, so I can change > it to 2-line mode. Also, any pointers to a good reference > book/article on controlling LCDs -- one that might have all the > control instructions such as the above 3 listed in it -- would be > appreciated. Mike: The first instruction, "00110000", is called "Function Set". Its bits are structured as follows: 001LNF00 - L: Interface Data Length (0=4 bits, 1=8 bits) - N: Number of Display Lines (0=1 line, 1=2 line s) - F: Font (0=5x7, 1=5x10) The next instruction, "00001110", is called "Display On/Off Control". The structure of this instruction is: 00001DCB0 - D: Display On/Off (0=Off, 1=On) - C: Cursor On/Off (0=Off, 1=On) - B: Blink at Cursor position On/Off (0=Off, 1=O n) The final instruction "00000110", is called "Entry Mode Set". It's structured as follows: 000001JS - J: Cursor-Move Direction (0=Rightward, 1=Leftward) - S: Shift (0=Leave Display static & Move Cursor , (1=Leave Cursor static and Shift Disp lay) To modify this code for a 2-line display, change the first instruction to "00111000". Remember that the LCD controller treats each line of the display as though it were 64 columns wide, so the address of the first character of the second line is 40 hex, no matter how wide your display actually is. For more information, get the LCD databook from Hitachi, AND, Stanley, EPSON, or any of the other manufacturers of these things... They all use the same Hitachi LCD controller chip. -Andy Andrew Warren - fastfwd@ix.netcom.com Fast Forward Engineering, Vista, California http://www.geopages.com/SiliconValley/2499