> I have a snippet of code here which is from a Parallax app note > on interfacing a PIC to a standard character LCD module. > ...snip... > > Anyway, according the that lone comment, this code sets the LCD to > 8-bit, 1 line operation. 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. When you say "standard character LCD module" you seem to mean an LCD module using an Hitachi HD44780 Dot Matrix LCD Controller/Driver. This is a _very_ common controller chip for small one, and two, line displays; but "standard" might be stretching it. You need a copy of the "Hitachi LCD Controller/Driver LSI" databook. Or a datasheet for the HD44780 (or HD44780A, or LCD-II, or other compatible) IC. To keep you going, here is the command set for the chip: 00000001 Clear display and Home cursor 0000001* Home cursor 000001AB Set cursor move and display shift 00001CDE Turn on/off display, cursor, blink 0001FG** Move cursor and shift display 001HJK** Set interface, lines, font 01aaaaaa Set character generator address 1aaaaaaa Set data ram address (Set cursor) Where: * = don't care (usually set to 0) A = 1 for cursor increment, 0 for cursor decrement B = 1 for display shift on cursor move, 0 otherwise C = 1 to turn display on, 0 to turn display off D = 1 to turn cusor on, 0 to turn cursor off E = 1 to turn cursor blink on, 0 to turn blink off F = 1 to shift display, 0 to move cursor G = 1 to shift/move to the right, 0 to move left H = 1 for 8-bit interface, 0 for 4-bit interface J = 1 for 2-line display, 0 for 1-line display K = 1 for 5x10 dot characters, 0 for 5x7 characters All these instructions must be written to the command register (RS=0, R/W=0). Having configured the display and set the cursor, you then display characters by writing ascii codes to the data register (RS=1, R/W=0). You cannot send commands/data to the chip while it is busy. You must poll the BUSY flag by reading the command register (RS=0, R/W=1). The BUSY flag is bit#7, and is high when the chip is busy. Bits #6..#0 are the current data ram address (cursor address). If you don't want to poll the BUSY flag you must provide software delays that are long enough to ensure the chip has finished executing each command that you send. The execution time of all commands is 40us, except for the "Clear display" and "Home cursor" commands, which both take 1.64ms to execute. Note that the '44780 chip is difficult to initialize. The built-in power-on reset circuit is unreliable, and a software initialization sequence must usually be executed. ___Bob