I just transitioned a new product design from a WINDSTAR 2x16 LCD to a NEWHAVEN 2x8 LCD to save a few bucks parts cost and some panel space on the product front panel, plus the NEWHAVEN operates without a backlight. I had the PBPro code working fine with the WINDSTAR while using it as a 4-bit interface display. I notice that the WINDSTAR LCD uses a ST7006U controller while the NEWHAVEN uses a SPLC780D, but the Command/Instruction tables are identical for both LCDs. I presumed that since the NEWHAVEN LCD is also a 4-bit interface display, has exactly the same electrical interface, and the Instruction Table is the same, that all I would have to do is change those lines of code that placed the characters on each line so that they fit inside of the 8 available characters per line. In fact, I can't get any characters to appear on the screen of the NEWHAVEN display. The Newhaven data sheet includes example initialization routines in C, but I don't understand C so can't replicate in PBPro. I am attaching my PBPro initialization routine for the WINDSTAR and the C code routines for the NEWHAVEN. Can anyone advise me how to change my PBPro code to match this C code??
Here is the C code routines that came with the NEWHAVEN:Code:InitializeDisplay: ' Subroutine to initialize 2X16 LCD display '================= '-----SETUP FOR USING 2x16 LCD THAT IS INSTALLED IN EASYPIC6-------- ' Blink LED_GRN twice to indicate entered IntializeDisplay For i = 0 to 1 HIGH LED_GRN Pause 500 LOW LED_GRN PAUSE 500 Next ' LCD DEFINES FOR USING 2x16 LCD with PortA in EASYPIC6 DEFINE LCD_DREG PORTA ' Use PORTA for LCD Data DEFINE LCD_DBIT 0 ' Use lower(4) 4 bits of PORTA ' PORTA.0 thru PORTA.3 connect to ' LCD DB4 thru LCD DB-7 respectively DEFINE LCD_RSREG PORTA ' PORTA for RegisterSelect (RS) bit DEFINE LCD_RSBIT 4 ' PORTA.4 pin for LCD's RS line DEFINE LCD_RWREG PORTC ' LCD read/write port DEFINE LCD_RWBIT 2 ' LCD read/write bit DEFINE LCD_EREG PORTA ' PORTA for Enable (E) bit DEFINE LCD_EBIT 5 ' PORTA.5 pin for LCD's E line DEFINE LCD_BITS 4 ' Using 4-bit bus DEFINE LCD_LINES 2 ' Using 2 line Display DEFINE LCD_COMMANDUS 1500' Command Delay (uS) DEFINE LCD_DATAUS 44 ' Data Delay (uS) ' DEFINE LCD Control Constants Line1 CON 128 ' Point to beginning of line 1 ($80) Line2 CON 192 ' Point to beginning of line 2 ($C0) ' Test the LCD during initialization LCDOut $fe,1:FLAGS=0:Pause 250 ' Clear Display LCDOut $fe,Line1+3," LCD TEST " ' Display on 1st line Pause 500 LCDOut $fe,Line2+2,"..Power On..!!" ' Display on 2nd line PAUSE 1000 Return
Code:4-bit Initialization: /**********************************************************/ void command(char i) { P1 = i; //put data on output Port D_I =0; //D/I=LOW : send instruction R_W =0; //R/W=LOW : Write Nybble(); //Send lower 4 bits i = i<<4; //Shift over by 4 bits P1 = i; //put data on output Port Nybble(); //Send upper 4 bits } /**********************************************************/ void write(char i) { P1 = i; //put data on output Port D_I =1; //D/I=HIGH : send data R_W =0; //R/W=LOW : Write Nybble(); //Clock lower 4 bits i = i<<4; //Shift over by 4 bits P1 = i; //put data on output Port Nybble(); //Clock upper 4 bits } /**********************************************************/ void Nybble() { E = 1; Delay(1); //enable pulse width >= 300ns E = 0; //Clock enable: falling edge } /**********************************************************/ void init() { P1 = 0; P3 = 0; Delay(100); //Wait >15 msec after power is applied P1 = 0x30; //put 0x30 on the output port Delay(30); //must wait 5ms, busy flag not available Nybble(); //command 0x30 = Wake up Delay(10); //must wait 160us, busy flag not available Nybble(); //command 0x30 = Wake up #2 Delay(10); //must wait 160us, busy flag not available Nybble(); //command 0x30 = Wake up #3 Delay(10); //can check busy flag now instead of delay P1= 0x20; //put 0x20 on the output port Nybble(); //Function set: 4-bit interface command(0x28); //Function set: 4-bit/2-line command(0x10); //Set cursor command(0x0F); //Display ON; Blinking cursor command(0x06); //Entry Mode set } /**********************************************************/








Bookmarks