Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

GAH!!! stupid LCD :)

Status
Not open for further replies.

DanD

New Member
so for two days now i have been trying to get this basic HD44780 based 16x4 LCD to work.

I'm running a PIC18F4480 and have the LCD wired up in 4 bit mode to PORTC. Power, ground, and contrast check out w/ multmeter and i can dim the display, etc w/ the contrast pot. i checked my soldering and there are no shorts between pins, etc and i checked continuity from the chip pin to the LCD pin. theyre all good.

im programming my project in C using the C18 compiler. I starded using the included C18 LCD libraries (xlcd.h) and it seems straight forward. i edited the xlcd.h to reflect my hardware setup. Just calling OpenXLCD(config) should get me a blinking cursor.. but nothing but a blank display.

so i fiddled w/ other bits of random C and assembly code out there including Nigel's tutorials. The best icoudl get was random black boxes on the display. no discernable characters. I also got a blinking cursor w/ Nigel's display, but that was all.

So what are some good first places to look in finding the problem? i put LEDs on some of the control pins so i could visually see what was going on there. they seem to be behaving ok. i've read the data sheets and have a decent understanding of how this works.. but i havent written any code from scratch yet.. i figure i should be able to get SOMETHING already written to work.

what the most basic test i can do? Is there anything weird about PORTC i should know about?

Thanks
 
i'm debugging w/ the Watch window in the MPLAB IDE and for some reason the PORTC register is showing x00 after i run the LCD even though i can probe the pins w/ a multimeter and see that they some (E, R/W) are 1!

wth? i'm thoroughly baffled
 
This is only a guess. On PIC processors it it common to have multiple functions multiplexed on a single port. The MPLAB simulator will give you this clue if the setup for a port selects an alternate function. You will not see what you wrote.

Go back to the datasheet for the part and read the section describing PORT C very carefully. Look for any hint that there is an alternate function, and that it might be the power up default.
 
the only goofy things i see is that the timer1 oscillator input/output is on that port and it says it WILL override the TRIS settings. i disabled it, but still no luck. i'm going to try a new port tomorrow and see what happens

doh, just tried w/ PORTD. same thing..
 
Last edited:
more info: upon powering on, the first and third rows go dark. the 2nd and 4th are totally blank. by dark i mean like dark if you turn the contrast up. not dark as in actually written. the few tiems i saw data being written it was definately darker than this dark and appeared only on these initially dark rows.

does this mean the lcd is never initialized? it should clear upon initialization i belive
 
well, it should clear on clear. as I recall, init doesn't clear but it's been a while and the first command I issue is always clear. make sure you are leaving enough time for init. The 44780 is very picky that way. my bets are on something not right in your init code. also make sure all the pins are properly connected and you've tris'd them properly.
 
Hello!

I'm not quite sure if the 16*4 behave like the 20*4 but your screen seems to have a comportement like my 20*4. I tried almost anything to make it work correctly but usually, I just obtained nothing and/or junk on the display. The solution, found on another forum, was to send the initialisation sequence 3 times at the beginning. Since that, it works quite well! You can see my code there: **broken link removed**
 
hrmm i tried to init 3 times.. no luck. :( ill try your code later on.

i'm using the internal osc running at 8MHz. could this be a problem?
 
To be sure that it's not a timing problem, try to put LONG delays between any action. It'll be slower but you'll know if it's your problem.
 
ok, i retested/measured my msDelay function using the simulator adn teh stopwatch. then i tripled all the delay calls.. still no dice.

i tried your code up there, but i kept getting linker errors and im a bit unsure of how you use your routines.

this is crazy. its stressing me out way more than it should.

AHHHHHHHHHHHHHHHHHHHHHH

im going to start from scratch w/ a simple program later after work and see what happens. ill post then code if it doesnt work. thanks
 
First off, just leave everything set up the way it was. Unplug the LCD. Make a task just go "CS_N=1; CD=1; DATA=1; LCDCLK=1; CLRWDT(); CS_N=0; CD=0; DATA=0; LCDCLK=0;" in a continuous loop. Check your pins and see if they're all flipping. If you don't have an oscilloscope (you poor man) then just use a multimeter, it should read a bit over 2.5v. Well you'll know the pins are set up to be driven and you're looking at the right set of pins.
 
i was probing w/ a MM but found it a bit inaccurate. i do have an oscope so ill play w/ that as well (i design/build tube guitar amps, much easier than this crap :p). do you think the MPLAB's Watch util is accurate? If so its not showing ANY activity on the port i want.. but i DO measure some w/ the MM.. ugh.

thanks all
 
ah ah! well i got Nigel's tutorials to work. im not sure how, but i just copied and pasted them into a new project and voila! so thats reassuring and tells me a lot.

unfortunately theyre in asm and my project is in C. so now i'm working w/ the C18 xlcd libraries. I have seen this thread:
http://forum.microchip.com/tm.aspx?m=159943

Why does he say to recompile the libraries after only editing the xlcd.h file? this file is included in my main.c file and should be compiled automatically right? am i missing something there?

still no luck w/ the xlcd libs.. chug chug chug
 
I dunno, maybe I missed somthing but the .h file contains definitions, you will want to change them before you use them, right?
 
oh ****..

i havent been explicitly compiling any libraries all this time.

so should i copy all the library source to my project directory? and then add them in under Source in the IDE? and then compile?

how should i properly do this?

edit: ah haaaaa well i tried just what i said above adn im making progress. i now have a blinking cursor! and i can write, but instead of characters its black boxes w/ a single dot inside. thats cool though, im happy just to have made progress. hopefully i can figure the rest out
 
Last edited:
^thanks, ill check it out.

well after 5 more hours i have a blinking cursor (even tho i told it not to blink or show a cursor) that prints black boxes when i print a string. it also only initializes rows 1 and 3.

my code is so basicly simple i dont even know what to post. any tips on getting all 4 rows to intitialize? im using:

//OpenXLCD(FOUR_BIT & LINES_5X7);
OpenXLCD(FOUR_BIT & 0x28);

neither work. i'm also waiting two seconds after power up before i call the openxlcd. i tried using the busy signal, but as a fall back plan im now using a 50ms delay between every command/input to the lcd
 
DanD said:
i'm also waiting two seconds after power up before i call the openxlcd. i tried using the busy signal, but as a fall back plan im now using a 50ms delay between every command/input to the lcd
The busy flag, my favoriet :)
But, you can't use the busy flag during initialisation...
During initialisation you have to wait the times described in the datasheet already posted by Philba https://www.axman.com/support/CME-8GB60/Seikolcd.pdf
I never wait at power up for sending data the a LCD.
Forget about the 2 seconds after power up and focus on your initialisation routine.
I get back later with my sequence that never failed (so far) :)
 
true true. i just have a long (too long) delay before the init.

please do post your fail-proof code

:-D
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top