View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
LCD_init & Switching LCD Power w/ a FET |
Posted: Mon Dec 18, 2006 9:28 am |
|
|
Hello All,
I've come up with a dead-end on the following problem and was wondering if someone might be able to shed some light on what I'm seeing.
18F6627
3.236
5V
40Mhz
Port E is used for LCD and pin-E7 is used to control a BJT which controls a FET gate for switching power on and off to the LCD module (it will also provide power to the back-light when I get the LCD working.)
I found that the LCD was unreliable... wouldn't always switch off, restart, etc. I've tracked the problem down to when I init the LCD. If I don't init the LCD the V at cycles normally from Vcc to Vss when toggling pin_E7. However, if I init the LCD the power at the LCD cycles between Vcc and Vcc-0.4 or so. Something in the init'ing of the LCD is causing problems and I can't figure out what. I though it may have been the mapping of the pins in the driver causing pin_E7 to get changed in a set_tris statement. But I tried it with an extra spare pin and... same problem
Any help would be greatly appreciated and if I can provide more info, just tell me what you need.
Also, why does the lcd_init hang the PIC when there is no LCD present?
Thanks,
John |
|
|
davekelly
Joined: 04 Oct 2006 Posts: 53 Location: Berkshire, England
|
|
Posted: Mon Dec 18, 2006 10:09 am |
|
|
1. Make sure you delay enough between turning on the VDD to the LCD and init'ing the LCD, typically over 30 ms.
2. The hanging is probably caused by using the R/W pin method, where it polls the busy flag to check if the previous operation has completed. If using one of the FlexLCD libraries or similar, either disable the use of this pin, or use a #ifdef to not compile the whole LCD_init function function when you don't have it present (or simulating). |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Mon Dec 18, 2006 10:14 am |
|
|
The PIC hangs because the initialize routine includes a check to see if the LCD's busy flag/line is set:
Code: | while ( bit_test(lcd_read_byte(),7) ) ; |
This line is in the lcd_send_byte() function.
The odd power behaviour is very likely caused by the LCD's controller chip getting power from a high logic line coming from the PIC. To shut off the LCD, modify your routine to set all data and control lines between the PIC and the LCD low, then turn off the power. |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Mon Dec 18, 2006 10:55 am |
|
|
Dave & Newguy,
Thanks. That was quick and easy.
I didn't think to check the lcd_send_byte() function. I've been in a haze after trying to figure this out for so long. I understand now.
Newguy, that was it. Just setting all the porte pins low solved the problem. Not sure why that never occured to me... other than being clueless.
John |
|
|
|