Sorry I mistyped it I use 4 higher data bits of the LCD.
I could make it work at last just before going to sleep yesterday.
here is the code for a PIC16F684, hope it can be of help:
' Set LCD Data port
DEFINE LCD_DREG PORTC
' Set starting Data bit (0 or 4) if 4-bit bus = portC bit 0 for LCD Data bit 4
DEFINE LCD_DBIT 0
' Set LCD Register Select port
DEFINE LCD_RSREG PORTA
' Set LCD Register Select bit
DEFINE LCD_RSBIT 4
' Set LCD Enable port
DEFINE LCD_EREG PORTA
' Set LCD Enable bit
DEFINE LCD_EBIT 5
' Set LCD bus size (4 or 8 bits)
DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
' Set command delay time in us
DEFINE LCD_COMMANDUS 2000
' Set data delay time in us
DEFINE LCD_DATAUS 50
CLEAR
CMCON0 = %00000111 'comparators OFF, val = 7
ANSEL = %00000000 'choose digital i/o, val = 0
OPTION_REG = %01111111 'enable internal porta weak pullups resistors
WPUA = %010000 'enable weak pull ups for RS bit
TRISA = %000000
TRISC = %000000
PORTA = %000000
PORTC = %000000
Pause 2000 ' Wait for LCD to startup
START:
FLAGS = 0
loop:
WPUA = %010000 'enable weak pull ups for RS bit
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "wpua" ' Display Hello
Pause 500 ' Wait .5 second
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "010000"
Pause 500 ' Wait .5 second
pause 2000
HIGH PORTC.5 'turn on backlight
HIGH PORTC.4
LOW PORTC.5 'turn of backlight
LOW PORTC.4
Goto loop ' Do it forever
END




Bookmarks