Hi guys,
I'm trying to use a Hitachi 44780 compatible LCD module with a pic16F684 but it does not work.
All I see is a peristent row of black blocks.
I connected:
LCD to PIC
----------
RS (pin 4) to PIC RA4
E (pin 6) to PIC RA5
R/W to GND
D4 to RC0
D5 to RC1
D6 to RC2
D7 to RC3
D8 to RC4
Of course I connected the Pin1 (vss) to GND and VDD to +5V and VO (pin3) to a trimmer to adjust the contrast.
I connected pin 16 (backlight GND) to a transistor to PIC pin RC4 in order to control backlight in software. Pin 15 (+5V) is connected to +5V.
My code is:
' 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: Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second
pause 2000
HIGH PORTC.5 'turn on backlight
LOW PORTC.5 'turn of backlight
Goto loop ' Do it forever
END
CAN SOMEONE HELP ME PLEASE
Bookmarks