PDA

View Full Version : LCD display on PICDEM 2 Plus board



klausmikkelsen
- 16th December 2003, 15:31
I am brand new to Microchip controllers, but have extensive experience with Motorola, especially the cpu32K line.

Have a PICDEM 2 Plus board with an 18F452 that I can make do what I want with the exception of the LCD. It is in 4 bit data mode RD0-RD3 and control bits on RA 1,2 and 3 for E, R/W and RS respectively.

I am using the following lines of code. Any suggestions?




DEFINE OSC 4

DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 3
DEFINE LCD_EREG PORTA
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2

TRISA = $00
TRISD = $00
PORTA.2 = 0
PAUSE 1000

LOOP:
LCDOUT $FE, 1
PAUSE 100
LCDOUT $FE, $0F
PAUSE 100
LCDOUT $FE, $80
PAUSE 100
LCDOUT "Hello"
PAUSE 100

GOTO LOOP


Thanks,

Melanie
- 16th December 2003, 15:51
You could try the following...

Firstly since the R/W line is connected you should define it along with the other LCD defines...

DEFINE LCD_RWREG PORTA
DEFINE LCD_RWBIT 2

Secondly, as in most PIC's with multiplexed Analogue inputs on PortA, the default on power-up for RA0, 1, 2, 3 and 5 is Analogue mode. You need to switch those pins to Digital mode. Add this statement along with your TRISA etc...

ADCON1=$07

See section 17 of the 18F452's Datasheet for an explaination of what I've done.

Hopefully that will get you up and running.

Melanie

klausmikkelsen
- 16th December 2003, 17:11
Thanks, Melanie, that worked like a charm.