PDA

View Full Version : LCD problem with 16F877



alexx_57
- 23rd July 2007, 23:22
Hi Guys, first of all sorry about my bas english, i'm from argentina.
I'm new on PBP programming, i'm having troubles connecting my lcd to pic
I bought a pic16f877A and a pic16f84A, i connect my lcd usind the default circuit present on pbp manual, now, the circuit works fine using pic16f84 but when a use the 16f877 i see nothing on the display, y add the line CMCON1=7 to convert analog inputs to digital, but do the same thing, in both cases i use a 4mhz xtal, the code i'm using is the example included in pbp.
any help would be very preciate,Thanks a lot.

Alex

paul borgmeier
- 23rd July 2007, 23:49
y add the line CMCON1=7 to convert analog inputs to digital

The 877A does not have a register named CMCON1 - try

ADCON1 = 7

Post your code - otherwise we just have to guess

alexx_57
- 24th July 2007, 00:49
Thamks for the answer,
this is the code i used

' PicBasic program to demonstrate operation of an LCD in 4-bit mode
'
' LCD should be connected as follows:
' LCD PIC
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
' E PortB.3
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (or ground)
' DB0-3 No connect
ADCON1=7
Pause 500 ' Wait for LCD to startup

loop: Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second

Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second

Goto loop ' Do it forever

the lcd is connected in 4bit mode with pullup resistor on porta.4, i'm compile the program with: pbp lcd.bas -p16f877a
I probed tu pic using blink exammple, ands works fine, the led blinks.

paul borgmeier
- 24th July 2007, 14:03
Everything appears correct (as I am sure you know) - things to try and see

- Add another Pause 1000 below ADCON1=7 (for now to give everything more time to settle)
- Add your blink routine at the top to make sure your PIC is alive with this program
- Is MCLR pulled high?
- Do you have both VSS pins connected to GND
- Do you have a decoupler CAP between VDD and VSS?

Let us know

alexx_57
- 24th July 2007, 16:05
Hi paul, thanks for your time, currently I have 4,7k resistor on MCLR pin, both vss are connected to gnd and both vdd to +5v. No decoupler caps, i will make a test with a .1uf ceramic cap.
I made the circuit over a breadboard, could be that???
cheers.

Alex

paul borgmeier
- 24th July 2007, 16:15
Hi paul, thanks for your time, currently I have 4,7k resistor on MCLR pin, both vss are connected to gnd and both vdd to +5v. No decoupler caps, i will make a test with a .1uf ceramic cap.
I made the circuit over a breadboard, could be that???
cheers.

Alex

I run LCDs connected from breadboards all the time and they always work - try adding 10uF decoupler in addition to your .1uF bypass on both sets of VDD and VSS.

What brand of LCD? (I know it works for you on the 84A)

Are you sure this 877A PIC is alive with your current program?

mackrackit
- 24th July 2007, 17:51
The 877A does not have a register named CMCON1
But it does have a CMCON:)

Try adding to the top of your program


CMCON = 7
TRISA = %00000000

mackrackit
- 24th July 2007, 17:58
BTW, check this out
http://www.picbasic.co.uk/forum/showthread.php?t=3317

mackrackit
- 24th July 2007, 18:40
I re-read post #1 OOPPSS :o
I thought you were using the "A". But do try the TRISA part.

alexx_57
- 24th July 2007, 22:11
Hello, it works :-), finally i found the problem, it was lcd backlight, in the morning i made some test, for some reason when i disconnect the lcd backlight the entire screen show up black boxes,i change the contrast resistor and could see characters,...nothing more to say, at this moment is working with backlight, one again sorry about my english and thanks to all!!!

Alex.

paul borgmeier
- 25th July 2007, 13:47
Glad it works but I am confused ... what is wrong with your English?