Page 1 of 1

16X2 LCD

Posted: Fri Aug 05, 2011 11:59 pm
by greentech
Hi there,

I am trying to run 16x2 LCD which runs fine when i connect it with port B. but with port A the enable bit is a little problematic, all connections of LCD on port A including rs bit and enable bit does not work, but if i connect the enable bit with some other port it works fine, my hardware needs the lcd to be connected to port A, how can i resolve this?

Re: 16X2 LCD

Posted: Sat Aug 06, 2011 9:36 am
by JohnCrow
Hi
Using the LCD on Port A is dependant on what device you are using

I have used it on Port A with the 16F877A, but it cannot be used with the 16F88 for example

See Martins comments on a similar question I posted a while ago

http://www.matrixmultimedia.com/mmforum ... lcd#p24562

Re: 16X2 LCD

Posted: Sat Aug 06, 2011 9:56 am
by greentech
its 16f877a john.

Re: 16X2 LCD

Posted: Sat Aug 06, 2011 11:54 am
by medelec35
Hi greentech,
RA4 is open Drain, which means you need a pull up resistor connected between RA4 and +5V.
Something like 4K7 or higher. (will only need to be lower if driving a LED)
So when RA4 is at logic 1 the output transistor is switched off, so its pin is allowed to be pulled high since it acts like an open switch.
When RA4 is at logic 0 , the output transistor is switched on so the pin is like a short circuit to GND

The odd thing is the enable is connected to RA5 by default.

If you have an LED board you can connect that up, and set port to 255 and flash at 1Hz, to check RA4 and RA5. (RA4 will be dimmer as stated above)
So if RA5 doe not light, faulty connection/chip etc. You could try continuity tests to determine this.

Martin

Re: 16X2 LCD

Posted: Sat Aug 06, 2011 2:28 pm
by greentech
I HAVE PULLED UP RA4 WITH 4K7 ALSO TRIED WITH 10K, BUT LCD DOES NOT WORK.......

Re: 16X2 LCD

Posted: Sat Aug 06, 2011 2:57 pm
by medelec35
Have you toggled the the whole of port A at 1Hz and checked each pin goes from 0 to 5V and back to 0V?
Also could you have two pins shorted together?
A good way would be to create a simple light chaser.
If was me and I can't get the LCD to work on a port, then I would first confirm each pin is capable of going high then low. If it can I would concentrated on wiring between target device and LCD. I would check connections between each pin of microcontroller and LCD, for continuity, and shorts across adjacent pins.
Do you get the usual row of black squares?

I may have access to 16f877a on Monday, If so I can confirm if LCD eblock works on portA ok although I don't see why it won't.

Did You want me to take a look at your flowchart?
Although I can't see there being an issue with that.

Sorry Can't think of anything else to try.

Edit just remembered:
medelec35 wrote: Whereas with 16F877A RA0 - RA5 are bidirectional.
Although RA4 is open drain, all lines of LCD except Enable (RA5) have pull-ups.
That's why LCD works on port A
So in theory that pull-up is not necessary since the pull-up resistor is built in to LCD
Sorry about that.

Martin

Re: 16X2 LCD

Posted: Sat Aug 06, 2011 5:09 pm
by greentech
I HAVE WITTEN A VERY SIMPLE PROGRAM IN A WHILE LOOP


LCD INITIALIZE,
PRINT ASCII "HELLO WORLD" and i get the usual row of black squares :)

I Haven't tested the light chaser prog, but i will do that now and let you know the updates.

thanks for looking into the problem.

Re: 16X2 LCD

Posted: Mon Aug 08, 2011 9:46 am
by DavidA
Hello,

Make sure your "Start LCD" macro call is outside of the loop and is only called once at the start of the program, else you will get the black squares.

Re: 16X2 LCD

Posted: Mon Aug 08, 2011 5:57 pm
by Benj
Hello,

Please can you attach your program and I will have a look for you. I'm guessing the problem is with the clock speed or config settings.
Make sure your "Start LCD" macro call is outside of the loop and is only called once at the start of the program, else you will get the black squares.
What David says is true as far as the LCD will not start up without calling the LCD Start macro in your program before sending any other commands to the display.

Any further component macro calls to the start function will have the effect of resetting and clearing the display. This can be used to recover the display in cases where interrupts or other non synchronous code is used to drive the display and the display has become corrupted due to two commands colliding.

Re: 16X2 LCD

Posted: Wed Aug 10, 2011 11:47 am
by greentech
BENJ I SOLVED IT, AND IT SEEMS TO WORK FINE NOW. I placed a pull up resistor at RA4 and now its working fine. clockspeed and other configs were alright.