LCD programming with PIC

Thread Starter

Zeta7

Joined Mar 9, 2011
1
Greetings,

I am new to the PIC Micro world although I have experience in the 80C51 world. I have copied the code that MMcLaren has posted here and have connected the PIC 16F690 as shown in his diagram as well. However, I get absolutly nothing displayed on the LCD. Is there someone out there that can help me get a single character displayed on this 44780 LCD panel (It is 20x4)?

BTW, I am using te low pin count demo board that came with the Pickit2 and had realized that RC7 was not connected to the demoboard's headder so I changed the code to use RC5 instead. Still no display.
 

MMcLaren

Joined Feb 14, 2010
861
Hi Zeta7,

With the LCD 'E' pin connected to RC5, the PutNyb code should look like this;

Rich (BB code):
PutNyb
        andlw   0x0F            ; mask off left nybble            |B0
        iorlw   b'00010000'     ; set lcd RS bit (RC4)            |B0
        skpc                    ; C=1 (RS=1)? yes, skip, else     |B0
        xorlw   b'00010000'     ; clr lcd RS bit (RC4)            |B0
        movwf   PORTC           ; assert D7..D4 & RS pins         |B0
        iorlw   b'00100000'     ; set lcd E bit (RC5)             |B0
        movwf   PORTC           ; E = 1 (strobe)                  |B0
        xorlw   b'00100000'     ; clr lcd E bit (RC5)             |B0
        movwf   PORTC           ; E = 0                           |B0
        return                  ;                                 |B0
You might also add a clrc instruction in front of the first DelayCy(30*msecs) instruction in the LCD initialization code. It shouldn't be necessary because of the clrf STATUS instruction at the reset vector but if you've added any code to the program you may have accidentally upset the Carry status flag before we get to the LCD initialization code.

Cheerful regards, Mike

Rich (BB code):
;
;  initialize LCD in 4-bit interface mode
;
        clrc                    ;                                 |B0
        DelayCy(30*msecs)       ; delay 30-msecs after power up   |B0
 
Last edited:

spinnaker

Joined Oct 29, 2009
7,830
Greetings,

I am new to the PIC Micro world although I have experience in the 80C51 world. I have copied the code that MMcLaren has posted here and have connected the PIC 16F690 as shown in his diagram as well. However, I get absolutly nothing displayed on the LCD. Is there someone out there that can help me get a single character displayed on this 44780 LCD panel (It is 20x4)?

BTW, I am using te low pin count demo board that came with the Pickit2 and had realized that RC7 was not connected to the demoboard's headder so I changed the code to use RC5 instead. Still no display.
What language and what compiler?
 

spinnaker

Joined Oct 29, 2009
7,830
It was assembly language using MPASM. Here's the code from the original thread.

Cheerful regards, Mike, K8LH

Why do you want to punish yourself with assembler too? Using C would be a log easier and there are already tested functions out there.

Assuming you have debugged you code, and all the pins on the LCD toggle like they are supposed too, the next most likely cause is timing. Delays between commands and characters. Search on this forum. I believe it was ThatOneGuy that posted recommendations on timing.

This all assumes your code is working properly in the first place and it is initializing the LCD correctly.
 

MMcLaren

Joined Feb 14, 2010
861
Hi Spinnaker,

I'm not sure if you're addressing Zeta7 or me? I'll just mention that I do program in C as well as assembler but the original poster on the original thread was using assembler. Anyway, the example code works fine and the timing is right out of the HD44780 Datasheet and is derived from a cycle accurate general purpose delay subsystem that supports almost any clock (4, 8, 12, 16, 20-MHz, etc).

I'm sure that if you were to suggest looking at C as an alternative to assembler that it would seem much less abrasive than your criticism about using assembler.

Cheerful regards, Mike

 
Last edited:
Top