Tim Box developed a solution to interfacing 4 line LCDs and came up with the routine at the link shown.
( Because the mneumonic MOVFW is not recognised by the latest version of the optimiser, John Drew has changed all MOVFW instructions to MOVF to allow the optimiserin PDS to work.) Edit on 29/11/11 to add the macros, omitted in error by JD.
Print4line code
Save the code and then include it as shown in the example.
Code:
Device 18F4685
Declare Xtal 8
Declare PLL_Req = On
All_Digital=true
'setup alternative system for 4 line LCD
#disable Print
#disable Cursor
#enable DelayUS
Dim BPF As Byte System
Dim BPFH As Byte System
Dim GEN As Byte System
Dim PP0 As Byte System
Dim PP0H As Byte System
Dim PP3 As Byte System
Dim PP3H As Byte System
Dim PP4 As Byte System
Dim PP5 As Byte System
Dim LCD#ENPINSELECT1 As Bit
Dim LCD#ENPINSELECT2 As Bit
Symbol LCD#DATAUS = 50
Symbol LCD#COMMANDUS = 2000
Symbol LCD_ENPORT2 = PORTE
Symbol LCD_ENPIN2= 2 'the additional enable pin is on port E.2
LCD_DTPin = PORTB.4
LCD_RSPin = PORTB.3
LCD_ENPin = PORTB.2
LCD_Interface = 4 '4-bit Interface
LCD_Lines = 2 'in this case 2 lots of 2 lines
LCD_Type = 0
Declare Float_Rounding=On
Declare Float_Display_Type = fast
TRISB=%000000 'set ports for required input or output
TRISE=%000000
LCDCURSOR_12 Macro
LCD#ENPINSELECT1 = 1
LCD#ENPINSELECT2 = 0
Endm
LCDCURSOR_34 Macro
LCD#ENPINSELECT1 = 0
LCD#ENPINSELECT2 = 1
Endm
LCDCURSOR_1234 Macro
LCD#ENPINSELECT1 = 1
LCD#ENPINSELECT2 = 1
Endm
Include "Print4line.inc" '4 line routines
Test:
LCDCURSOR_12 'switch enable for first two lines
Print At 1,1, "Test line 1"
Print at 2,1, "Test line 2"
LCDCURSOR_34 'switch enable for the second set
Print At 1,1, "Test line 3"
Print at 2,1, "Test line 4"
End


Menu
Recent Articles


Using PDS with SPI GLCD based on ST7565R Controller
Graphic LCDs based on the ST7565 are cheaper then GLCDs with other controllers. SPI requires only four pins. If the circuit