By right it should not stray that far.... Is your chip really a Hitachi HD44870 chip or a compatible one? John --- Tarun Grover wrote: > I've recently completed a project involving an LCD > using this same > controller. What I found is that with the 2 LCD's I > was using for testing, > this initialization routine did not work. What I > found DID work was when I > left out > the first 3 'write4(3)' instructions. Now, this > goes against > everything I've read on the internet and from > Hitachi's Datasheet. I > only found 1 instance where someone used a different > initialization > scheme and this seemed to work for me. > > Was there anything wrong with what I was doing or do > different LCD's behave > differently (even though they use the same > controller)? > > Here is my initialization routine: > > void lcd_init(void) > { > LCD_EN_DIR = 0; //Set EN and RS > lines to output; > LCD_RS_DIR = 0; > > TRISBbits.TRISB0 = 0; //Set data lines > to output; > TRISBbits.TRISB1 = 0; > TRISBbits.TRISB2 = 0; > TRISBbits.TRISB3 = 0; > > LCD_EN = 0; > LCD_RS = 0; //Write control > bytes. > delay(1300000); > > PORTB = 0x0002; //Set 4 bit mode. > LCD_STROBE(); > > lcd_write(0x28); //4 bit mode, > 1/16 duty, 5x8 font. > lcd_write(0x08); //Display off. > lcd_write(0x0C); //Display on, > cursor on. > lcd_write(0x06); //Entry mode. > } > > Any insights? > > -Tarun. > > On 4/3/06, M. Adam Davis wrote: > > > > What is your LCD init routine? I've never > experienced that problem > > with the cheap LCDs I have used with this routine: > > > > write4 just writes 4 bits to the LCD interface, > write8 writes 8 bits > > in two cycles of 4 bits. The rest should be > pretty explanatory, > > except for the ??? which I sure could be > determined from the data > > sheet in short order. > > > > void initlcd(void) > > { > > delayms(20); // Wait for LCD to power > up ( >15ms ) > > RS=0; // Set RS low for > instruction > > write4(3); // Set interface to 8 bits > > delayms(5); // Wait for LCD execute > instruction ( >4.1ms ) > > write4(3); // Set interface to 8 bits > > delayms(1); // Wait for LCD execute > instruction ( >100us ) > > write4(3); // Set interface to 8 bits > > delayms(5); // Wait for LCD execute > instruction (At this point > > // we could actually start > using the busy flag) > > write4(2); // Set the display to 4 > bit interface > > delayms(5); // Wait for LCD execute > instruction > > write8(0x28); // Set the display to two > line and ??? > > delayms(5); // Wait for LCD execute > instruction > > write8(6); // ??? > > delayms(5); // Wait for LCD execute > instruction > > write8(1); // Clear the LCD > > delayms(5); // Wait for LCD execute > instruction > > write8(0xf); // ??? > > delayms(5); // Wait for LCD execute > instruction > > return; > > } > > > > -Adam > > > > On 4/3/06, kravnus wolf wrote: > > > I have written code for the LCD from bgmicro > > > > > > > > > http://www.bgmicro.com/prodinfo.asp?sid=0968912037037037604814310&prodid=LCD1022&page=1&cri=lcd&stype=3 > > > > > > I managed to get it started and printing > characters on > > > it. What grips me is that if I reset the PIC > through > > > MCLR quickly and numerous times the LCD just > prints > > > blank! It seems that the LCD cannot handle quick > > > restart over and over again. I am left > > > clueless........ > > > > > > Thanks, > > > John > > > > > > > __________________________________________________ > > > Do You Yahoo!? > > > Tired of spam? Yahoo! Mail has the best spam > protection around > > > http://mail.yahoo.com > > > -- > > > http://www.piclist.com PIC/SX FAQ & list archive > > > View/change your membership options at > > > http://mailman.mit.edu/mailman/listinfo/piclist > > > > > > > -- > > http://www.piclist.com PIC/SX FAQ & list archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > > > > -- > Tarun Grover > Computer Engineering & Management V > McMaster University, Hamilton, ON, Canada > Chair, McMaster IEEE Student Branch Computer Chapter > grovert@mcmaster.ca - tarun.grover@gmail.com > tarun_grover@ieee.org - 905-518-2743 > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist