PDA

View Full Version : Custom configuration for LCD module



aberco
- 23rd December 2007, 15:02
Hi everyone,
I'm actually experiencing troubles interfacing a 2x16 LCD module to a PIC18F2550 using a custom connexion scheme on port A.

However it seems to me that I did everything right, but can't get anything to display on my LCD.

I am using 4bit addressing mode, with:

PortA.0 to PortA.3 = D4 to D7
PortA.4 = E
PortA.5 = RS
R/W = GND

(hardware connexion was triple checked!!!)

-The LCD seems to initialize correctly after the first delay (when powered on the first line is darker, after the init. command is sent the LCD contrast is even on both lines), however nothing is displayed.

-I tried 3 different LCD's, 2 are displaying nothing, the first one a blinking cursor on the first character that just stay there

-contrast is likely not the issue as I can see caracter positions

-I also checked the signals with my oscilloscope, data is being sent on every lines (D4-D7, E and RS) at a 1/2s interval, corresponding to what my code should actually do.

Here is my code (that was started with easyHID, as I plan to use USB comm later on):

DEFINE OSC 48
DEFINE LOADER_USED 1

' Set ADC pins to digital operation
ADCON1 = 7

' Define pin function
'TRISA = %00000011
'TRISB = %10001111
'TRISC = %01111100

' set LCD pin configuration
DEFINE LCD_DREG PORTA
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 5
DEFINE LCD_EREG PORTA
DEFINE LCD_EBIT 4
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50

' Define pin names
BACKLIGHT VAR PORTC.0
USBPOWER VAR PORTC.1
CLK VAR PORTC.7
DAT VAR PORTC.6
CANCEL VAR PORTB.7
DOWN VAR PORTB.6
UP VAR PORTB.5
ENTER VAR PORTB.4
POWER VAR PORTB.3
RESET VAR PORTB.2
SDA VAR PORTB.0
SCL VAR PORTB.1

USBBufferSizeMax con 8 ' maximum buffer size
USBBufferSizeTX con 8 ' input
USBBufferSizeRX con 8 ' output

' the USB buffer...
USBBuffer Var Byte[USBBufferSizeMax]
USBBufferCount Var Byte

usbinit ' initialise USB...

' output state initialisation
LOW BACKLIGHT
LOW POWER
LOW CLK
LOW DAT
LOW RESET

' ************************************************** *********
' MAIN PROGRAM
' ************************************************** *********
Pause 1000

' writing custom characters in the LCD display memory
' character 0 tuning fork ($40)
LCDOUT $FE,$40,$0a,$0a,$0a,$0a,$0a,$04,$04,$00
' character 1 diËze ($48)
lcdout $FE,$48,$0a,$0b,$0e,$1b,$0e,$1a,$0a,$00
' character 2 bÈmol ($50)
lcdout $FE,$50,$08,$08,$0a,$0d,$09,$0a,$0c,$00
' character 3 hertz ($58)
lcdout $FE,$58,$14,$14,$14,$1f,$15,$16,$17,$00
' character 4 cent ($60)
lcdout $FE,$60,$02,$02,$02,$0b,$12,$12,$0d,$00

programstart:

lcdout $FE, 1
lcdout "abcdefghiklmnop"
pause 500
LCDOUT $FE, 1
lcdout "qrstuvwxyz"
pause 500

USBSERVICE

goto programstart



I'm running out of ideas about what can be wrong. Ideas anyone? thanks for the help

aberco
- 23rd December 2007, 16:21
Just tried again without the USB code, only with the strict minimum.

I remember that a friend couldn't get his LCD working with a PIC18F4550, whereas the same code was working perfectly on a 16F877...

Is there an issue with interfacing LCD's to USB PIC?

mackrackit
- 23rd December 2007, 16:44
Have looked at the comparators?
The16F877 did not have them.
http://www.picbasic.co.uk/forum/showthread.php?t=561

aberco
- 23rd December 2007, 17:16
Hahaha fast and efficient! you saved my day!

The ADC was actually on...

Had to add
ADCON1 =%00001111
CMCON = %00000111

Thanks a lot, and sory for this newbie question

mackrackit
- 23rd December 2007, 17:51
Thanks a lot, and sory for this newbie question
No problem, we all had/have them at some point. :)