PDA

View Full Version : 2x16 LCD Module with HD44780 + 16F877A



comwarrior
- 14th August 2009, 23:57
i've just baught the above LCD from a well known auction site (not sure if i'm allowed to say what)...

All the searches i've done point to LCD data lines on portA and IO on portB...
on the 16F877A, PortA and PortE are analogue and i'm using the analogue ports...

Can i change (somewhere) what pins the LCD is connected to and still use LCDOUT and LCDIN?

Thanks

mackrackit
- 15th August 2009, 02:19
Yes, look in your PBP manual and read about defining the LCD.
Here is an example (for a different PIC)


DEFINE LCD_DREG PORTG
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
DEFINE LCD_COMMANDUS 3000
DEFINE LCD_DATAUS 150

DREG has to be all on the same port, either upper or lower. DT has a LCD ANY PIN trick someplace if if you are adventurous :)

comwarrior
- 15th August 2009, 11:23
ahhh, yes, i remember reading about those now...

thanks dave

comwarrior
- 15th August 2009, 22:51
Is their any speed advantage to using 8 bits instead of 4?

thanks

Melanie
- 15th August 2009, 23:17
Yes, it's twice as fast!

mackrackit
- 15th August 2009, 23:52
Twice as many pins used or twice as fast. Take your pick.

comwarrior
- 16th August 2009, 00:13
and their i was thinking it used a more 'usefull' ASCII table... perhaps an EECII table... (English Enhansed Code for Information Interchange)...

Lol ;)

comwarrior
- 19th August 2009, 00:24
Can someone help me to debug this problem?

Above LCD with above PIC have been conected and programmed...

the LCD displays absolutly nothing not even at power on...
I have purchased two identical and neither display anything at power on...
I have a 38K serial2 going to a com port on my PC which works perfectly...

i'm using all 8 data bits connected to PORT D...
RS (pin 4) is connected to PORTC.5
RW (pin 5) is connected to PORTC.6
E (pin6) is connected to PORTC.7

Contrast is connected to +5V via 1.5K resister

My defines are as follows...

DEFINE LCD_DREG PORTD 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTC 'LCD register select port
DEFINE LCD_RSBIT 5 'LCD register select bit
DEFINE LCD_EREG PORTC 'LCD enable port
DEFINE LCD_EBIT 7 'LCD enable bit
DEFINE LCD_RWREG PORTC 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

TRISC and D are set to all outputs, i don't know if this is correct or not?

I think their is 'some' activity on the LCD data and controll lines but i only have a digital multimeter so, can't be sure.

I'm using PORTA and E for analogue, PWM 0 and 1 (RC1 and RC2), TMR1 in counter mode using PORTC0 as input and PORTB for digital output and SER2 PC telemetry link...

I have no idea where to begin to find the problem, so any help appreciated...

Thanks

mackrackit
- 19th August 2009, 00:44
Try the contrast like the example in the PBP manual. That is the safest way for unknown displays. Normally the contrast likes a little more - than + .

Another thing to double check is if the data lines are in the correct order when connecting to the PIC.

comwarrior
- 19th August 2009, 01:23
I'll try the contrast in the morning, i think i got a 10K pot somewhere...

I just wrote a simple "hello world" type LCD test program...

I loadedit into oshonsoft's pic simulator and configured it's LCD module...
Acording to the microcontroller view, all the data lines switch to outputs...
However, it gets into a loop with nothing displayed in the LCD module, and tmr1 prescaler is continueously counting up by 1 each loop but over flows without a change in instructions...

:edit after about 17000us in simulation RD0, RD1,RD5 and RD4 to high... still nothing on LCD module

:edit after 22000us in simulation it has now started putting charecters on the LCD...

mackrackit
- 19th August 2009, 01:52
Just for giggles, can we see the whole code?

comwarrior
- 19th August 2009, 02:07
@ device pic16F877A, HS_OSC
@ device WDT_OFF
@ device PWRT_OFF
@ device BOD_OFF
@ device LVP_OFF
@ device WRT_OFF
@ device CPD_OFF
@ device DEBUG_OFF

Define OSC 4 ' Set clock speed
DEFINE SER2_BITS 8 ' Ser2 number of data bits
DEFINE LCD_DREG PORTD 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTC 'LCD register select port
DEFINE LCD_RSBIT 5 'LCD register select bit
DEFINE LCD_EREG PORTC 'LCD enable port
DEFINE LCD_EBIT 7 'LCD enable bit
DEFINE LCD_RWREG PORTC 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us
'Pause 1000

loop:
LCDOUT $FE, 1, 2, "INITIALISING"
LCDOUT $FE, $C0, "Hello"
goto loop

comwarrior
- 19th August 2009, 19:38
Found it... looks like the contrast likes to be fully negative...

Thanks for the help... Iactualy thaught the contrast should be more positive acording to all the scmatics i looked at...

Thanks