LCD display on PICDEM 2 Plus board

Status
Not open for further replies.
I am brand new to Microchip controllers but have extensive experience with Motorola, especially the cpu32Kline.

Have a PICDEM 2 Plus board with a 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 lcd screen supplier 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,
 
Last edited:
Don't you also need to define the R/W port and bit?

LCD_RWREG - defines the port where R/W line is connected to (set to 0 if not used; 0 is default)
LCD_RWBIT - defines the pin where R/W line is connected to (set to 0 if not used; 0 is default)
 
You appear to be using a basic compiler, which one?

Your initialisation code is wrong, this is what I use (in C),
Code:
    RW=0;
    E=0;                            //clear enable
    RS = 0;                         //going to write command
    __delay_ms(30);                 //delay for LCD to initialize.
    writeNibble(0x3);              //Required for initialization
    __delay_ms(5);                  //required delay
    writeNibble(0x3);              //Required for initialization
    __delay_ms(1);                  //required delay
    writeCommand(0x20);             //set to 4 bit interface
    writeCommand(0x2c);             //set to 4 bit interface, 2 line and 5*10 font
    writeCommand(0x01);             //clear display
    writeCommand(0x06);             //move cursor right after write
    writeCommand(0x0C);             //turn on display
    writeCommand(0x01);             //clear display
The delay sequence is defined in the LCD datasheet.
I'm assuming that R/W is grounded.
Also, should DEFINE LCD_BITS 4 be DEFINE LCD_BITS 0 as it's using the lower nibble.

Mike.
 
thank you so much for your suggestion
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…