• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

Pic18f452 with 20x4 LCD Help

djmachine

New member
Hi I am trying to initialize a CFA2004ATMIJP 20x4 LCD using a Pic18f452 @ 10MHz with PicBasic Pro. After compiling and uploading the hex file the screen stays blank. I have a 10K pot on VO and have it at around 4.2V. The LCD backlight is lit and I have used this code for an 8x2 Optrex LCD with no problems. The only modifications to the code for this LCD are setting the amount of lines to 4 lines instead of 2, and using different DDRAM Addresses such as 0x00, 0x40, 0x14, 0x54 for the LCDOUT commands. Can anyone see where I am going wrong? Thanks!

I have verified with my dmm that all of the connections to the lcd and the pic are good and there are no shorts.

0.1uF cap acrosss (Vss and Vdd)

Vss = Gnd
Vdd = 4.96V
Vo = 4.2V
RS = PORTE.0
R/W = Gnd
E = PORTE.1

DB4 = PORTD.4
DB5 = PORTD.5
DB6 = PORTD.6
DB7 = PORTD.7

The Code
===========================

' PicBasic program to demonstrate operation of an LCD in 4-bit mode
'

DEFINE OSC 10

DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_LINES 4
DEFINE LCD_DATAUS 50


'Force LCD init
FLAGS=0
Lcdout $fe, 1 'Clear LCD screen
'LCD set-up time
PAUSE 2000
Lcdout $fe, 1 'Clear LCD screen


ASM

MOVLF macro literal,dest
movlw literal
movwf dest
endm

Initial
MOVLF B'10001110',ADCON1 ;Enable PORTA & PORTE digital I/O pins
MOVLF B'11100001',TRISA ;Set I/O for PORTA
MOVLF B'11011100',TRISB ;Set I/O for PORTB
MOVLF B'11010000',TRISC ;Set I/0 for PORTC
MOVLF B'00001111',TRISD ;Set I/O for PORTD
MOVLF B'00000000',TRISE ;Set I/O for PORTE
MOVLF B'10001000',T0CON ;Set up Timer0 for a looptime of 10 ms
MOVLF B'00010000',PORTA ;Turn off all four LEDs drssiven from PORTA
ENDASM


PORTA.4 = 0


loop:
LCDOUT $fe, $00, "LCD TEST" ' Display PULSVARs
LCDOUT $fe, $40, "THIS SCREEN" ' Display PULSVARs
LCDOUT $fe, $14, "IS 20 BY 4" ' Display PULSVARs
LCDOUT $fe, $54, "CHARACTERS BIG" ' Display PULSVARs

PAUSE 1000

TOGGLE PORTA.4 ;Heartbeat LED

Goto loop ' Do it forever

End
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
What is your reference for measuring Vo? The data sheet says that Vo should be about 4.5 volts, VDD - Vo, meaning referenced to +5 volts. That is easy to misinterpret. The Vo voltage should be in the neighborhood of 0.5 volts, referenced to GROUND. As you turn your contrast pot down below 1 volt, you should start to see some contrast.
 
Top