For the past few days Ive been working with a Newhaven 4x40 Character LCD. The Newhaven NHD-0440WH-ATMI-JT has duel ST7066U controllers. I have written an Initializing routine outlined in the datasheet but NOTHING. No cursor, no characters, NADA. I have tried PBP LCDOUT using E1 only, no luck here either. Even if that worked I am not sure how to handle E1 & E2 in the LCDOUT command. Can a port assinment DEFINE such as LCD_EBIT be changed with use of the bas. file, PORTL?
Blinky light routine works fine. Any Ideas anyone?
The datasheet reads as if the LCD is in fact two (2x40) LCDs
16F886 at 4Mhz
I tried to slow the 16F886 to 2Mhz, OSCCON=$50 but PBP didnt like it.
LCD pinout -------- 16F886 Pin#
1. DB7 ..PortA.7 .9
2. DB6 ..PortA.6 .10
3. DB5 ..PortA.5 .7
4. DB4 ..PortA.4 .6
5. DB3 ..PortA.3 .5
6. DB2 ..PortA.2 .4
7. DB1 ..PortA.1 .3
8. DB0 ..PortA.0 .2
9. E1 ..PortC.0 .11
10. R/W ..PortC.3 .14
11. RS ..PortC.2 .13
12. Vo . .Center pin 20k pot 0.5V
13. Vss . GND
14. Vdd ...5v
15. E2 ...PortC.1 ...12
16. NC . .GND
17. LCD+ 100 ohm to 5V
18. LCD- .GND
Code:;16F886 @ DEVICE MCLR_OFF,BOD_OFF,WDT_ON,LVP_OFF define osc 4 OSCCON=$60 ;70=8MHz, 60=4MHz, 50=2MHz, 40=1MHz. ANSEL=$00 ADCON0=$00 CM1CON0= 0 CM2CON0= 0 ANSELH=$00 PortA=0 PortB=0 PortC=0 TrisA=0 TrisB=0 TrisC=0 'Constents Wakeup CON $30 FunctionSet CON $38 ;Function Set = 8bit mode; 2-line; 5x8 DisplayON CON $0C ;Turn on display; no cursor DisplayOnBcursCON $0F ;display on with blinking cursor DisplayOFF CON $08 ;Turn off display EntryMode CON $06 ;Entry mode cursor increment ClearDisp CON $01 ;Clear display Home CON $02 ;cursor set to home position 'Variables Avar var byte Bvar var byte Cvar var byte Dvar var byte LED Var PORTB.1 E1 var PORTC.0 ;top 2 lines of display E2 var PORTC.1 ;bottom 2 lines of display RS var PORTC.2 RW var PortC.3 'EEPROM Data @0, " Hello World line1 " '20bites Data @20," Hello World line2 " '20bites address C0h E1 Data @40," Hello World line3 " '20bites Data @60," Hello World line4 " '20bites address C0h E2 Start: goto Main Blinky: led =0 for Avar=1 to 4 toggle led pause 500 toggle led pause 500 next avar return ;INIT_LCD_SUBS Command1: 'command sub for upper 2 lines PortA=Cvar Rs=0 RW=0 E1=1 pause 5 E1=0 return Command2: 'command sub for lower2 lines PortA=Cvar Rs=0 RW=0 E2=1 pause 5 E2=0 return Writedata1: 'Write to upper 2 lines PortA=Cvar Rs=1 RW=0 E1=1 pause 5 E1=0 return Writedata2: 'Write to lower 2 lines PortA=Cvar Rs=1 RW=0 E2=1 pause 5 E2=0 return TestBusyFlag1: 'waits until BF is clear to return PortA=$FF Rs=0 RW=1 E1=1 RBF: @nop @ BTFSC PortA.7 goto RBF Rs=1 RW=0 E1=0 return INIT_LCD: 'Wakeup Cvar = Wakeup gosub Command1 gosub Command2 pause 2 'Wakeup Cvar = Wakeup gosub Command1 gosub Command2 pause 2 'Wakeup Cvar = Wakeup gosub Command1 gosub Command2 pause 2 ;FunctionSet ;Function Set = 8bit mode; 2-line; 5x8 Cvar = FunctionSet gosub Command1 gosub Command2 pause 2 'Display Off cvar = DisplayOFF gosub Command1 gosub Command2 pause 2 'Display Clear Cvar = ClearDisp gosub Command1 gosub Command2 pause 2 'Entry Mode Set ;Entry mode cursor increment cvar = EntryMode gosub Command1 gosub Command2 pause 2 'Display On cvar = DisplayOnBcurs ;Turn on display; with blinking cusor gosub Command1 gosub Command2 pause 2 return Main: 'Write "Hello World" GOSUB Blinky GOSUB INIT_LCD Message_line1: Cvar=Home ;Set DDRam address for line 1 gosub Command1 avar = 0 ;starting address of EEprom first message Bvar = Avar + 20 WHILE Avar < Bvar read Avar, Cvar Avar = Avar + 1 gosub Writedata1 ;write Cvar(contents of EEProm character) to LCD pause 100 WEND Marktime: toggle led pause 1000 toggle led pause 1000 goto Marktime end
Bookmarks