View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
LCD Init Problems |
Posted: Wed Dec 20, 2006 10:55 pm |
|
|
Hello All,
This is kind of a continuation of this recent topic/problem:
http://www.ccsinfo.com/forum/viewtopic.php?t=29225
What I'm up against now is a random failure of the LCD to display on startup. By that I mean, everything works normally, PIC doesn't hang in the init_lcd function and contrast can be adjusted way up to show all pixels 'filled', but the display isn't showing the expected text just the solid blocks.
If I init the LCD twice prior to the main loop reliability gets better but not 100%. If I put an init_lcd in the main loop where I'm updating the text, I think I can say I get 100% reliability by the third write to the display. Also, if I put a large delay between powering up the LCD and init'ing it doesn't seem to help either.
Restarting is either through pulling the power connection to the board to cycle the power or pushing a reset button. Both cause the problem, so I don't think it's a power up problem?
Could there be a problem with the default port settings on power up that are causing this, and after a few inits it finally gets resolved?
I've also tried several displays with identical results.
Any help would be greatly appreciated.
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 20, 2006 11:18 pm |
|
|
1. What's the LCD manufacturer and part number ?
Do you have a link to the data sheet ?
2. What provides the power supply for this board ?
Is a wall transformer and a voltage regulator ?
3. What LCD driver are you using ? You don't have to post the code,
but tell us which one you are using.
4. Are these tests being done with the LCD power coming from
a transistor and FET circuit as described in your previous post ?
Have you tried disconnecting the LCD from this circuit, and just
use the normal power supply for it ? |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Thu Dec 21, 2006 8:14 am |
|
|
PCM,
Thanks for taking a look, here is the additional data:
1. Crystalfontz: CFAH1602B-YYH-JPV
http://www.crystalfontz.com/products/1602b-wt/CFAH1602BYYHJPV.PDF
2. 9V Battery or wall wart through a LT1521 LDO. 0.1uF + 10uF on input, 0.1uf + 4.7uF on output. 0.1uF + 10uF at LCD power pin on board. Problem occurs with all varieties of power.
3. CCS lcd.c
4. Yes and yes, with the same erratic results
It looks as though, if I put three lcd_init's 25mS apart, prior to the main loop I get 100% reliability. So it appears to be something with that....
Thanks,
John |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Thu Dec 21, 2006 10:41 am |
|
|
OK.
I started doing the math, and put 2 and 2 together and figured maybe the 40Mhz clock speed was causing problems. When I change from the PLL to 10Mhz it appears everything works normally with one init_lcd.
Can I modify the driver to put some delays in the functions to slow things down?
Thanks,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 21, 2006 11:32 am |
|
|
Quote: | When I change from the PLL to 10Mhz it appears everything works normally with one init_lcd. |
In the CCS LCD.c driver, there are six places where they delay
for a single instruction cycle. At 40 MHz, that's only 100 ns.
Code: | c:\program files\picc\drivers\lcd.c
93 delay_cycles(1);
95 delay_cycles(1);
98 delay_cycles(1);
110 delay_cycles(1);
122 delay_cycles(1);
124 delay_cycles(1); |
I went through this problem when I did the Flex 4x20 LCD driver.
I remember increasing one or two delays in that driver during
development, because it wouldn't work reliably on one of my
LCDs at 40 MHz. I looked at the timing diagrams in the LCD
controller data sheet to help me figure out which delays to increas.
A quick way to fix the CCS LCD.c driver would just be to
change all the delay_cycles(1) statements to delay_us(1).
This would increase the delays from 100 ns to 1 us. |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Thu Dec 21, 2006 3:41 pm |
|
|
PCM,
Thanks. I think that fixed it.
I didn't go back and look at the functions after the previous post. I'd like to think I would have caught the delay_cycles vs. delay_us....
John |
|
|
|