What would cause the LCD to just turn off (except for a single line across the screen)? I've interfaced this LCD with a PIC24F and, after I got the timing down, displaying text and graphics have been no problem. Now though, after attempting to add the touchscreen functionality, the LED is shutting down for no particular reason. I don't believe it has anything to do with the PIC as the LCD would actually go blank when I just hooked up 3.3VDC across the Left-Right portion of the touchscreen without any other connection to the microcontroller. Now I've got it setup that as I sense off of the bottom of the touch screen, I get the screen to switch between two screens, depending on which side of the screen I touch. The LCD still goes out and it isn't predictable (whether I switch quickly or slowly between the screens it still blanks out seemingly randomly). I've tried pull-ups on the reset and display off lines, pull-downs on the enable line, a 470uF cap across the 5VDC in. I've even added more delay time in my code between writes and so far nothing has helped. If you have ANY ideas I'd appreciate them...I actually have to present this Wednesday night and I can't afford to have it blanking out on me.
Here's my main LCD functions (minus my graphics functions)
**NOTE: I had to do a little bit of wierd shifting for LATB (I had to change one of the data pins mid project and that was the only way I saw of doing it)**
Here's my main LCD functions (minus my graphics functions)
Code:
void ConfigureLCD(){
ResetLCD();
Delay_config(1);
LCDCommandWrite(0x0400); // SYSTEM SET
LCDDataWrite(0x0300);
LCDDataWrite(0x0870);
LCDDataWrite(0x0070);
LCDDataWrite(0x0270);
LCDDataWrite(0x0420);
LCDDataWrite(0x0EF0);
LCDDataWrite(0x0280);
LCDDataWrite(0x0000);
LCDCommandWrite(0x0600); // GRAYSCALE
LCDDataWrite(0x0000); // originally 0x0010 (2 bits per pixel)
LCDCommandWrite(0x0440); // SCROLL
LCDDataWrite(0x0000);
LCDDataWrite(0x0000);
LCDDataWrite(0x0EF0);
LCDDataWrite(0x0600);
LCDDataWrite(0x0090);
LCDDataWrite(0x0EF0);
LCDDataWrite(0x0000);
LCDDataWrite(0x0000);
LCDDataWrite(0x0000);
LCDDataWrite(0x0000);
LCDCommandWrite(0x05A0); // HDOT SCR
LCDDataWrite(0x0000); // No horizontal scrolling
LCDCommandWrite(0x05B0); // OVLY
LCDDataWrite(0x0010);
LCDCommandWrite(0x05D0); // CRSFORM
LCDDataWrite(0x0070);
LCDDataWrite(0x0870);
LCDCommandWrite(0x04C0); // CRSDIR
ChangeLCDScreen(0); // Load 'Home' Screen
LCDCommandWrite(0x0590); // Turn Display On
LCDDataWrite(0x0140); // Layer 1 & 2 On w/o flashing, cursor off
Delay_config(0);
}
void ClearLCDL2(void){
int i;
LCDCommandWrite(0x0460); // Position cursor
LCDDataWrite(0x0600);
LCDDataWrite(0x0090);
LCDCommandWrite(0x0420);
for(i=0; i < ((0x28) * 240); i++) // 240 * APL
{
LCDDataWrite(0x0000);
}
}
void ClearLCDTextLayer(void){
int i;
unsigned char c;
c = 'A';
LCDCommandWrite(0x0460); // Position cursor
LCDDataWrite(0x00);
LCDDataWrite(0x00);
LCDCommandWrite(0x0420);
for(i=0; i < ((0x28) * 30); i++) // 30 * APL
{
LCDDataWrite(0x0200);
}
}
void ResetLCD(void){
Delay_config(0);
_RC8 = 0; // activate LCD reset
Delay_ms(1);
_RC8 = 1; // deactivate LCD reset
Delay_ms(3);
}
void LCDCommandWrite(unsigned int intDataByte){
LATB |= ((intDataByte & ~(0x0FE0)) * 256) + intDataByte; // Set DB[7:0]
LATC &= ~(0x0080); // clear !CS
LATC |= 0x0050; // !CS = 0, A0 = 1, R/!W = 0, E = 1
Nop8(); // 500ns delay
LATC ^= 0x0090; // !CS = 1, A0 = X, R/!W = 0, E = 0
LATB &= ~(0x1FE0); // clear LATB
}
void LCDDataWrite(unsigned int intDataByte){
//LATB |= intDataByte; // Set DB[7:0]
LATB |= ((intDataByte & ~(0x0FE0)) * 256) + intDataByte; // Set DB[7:0]
LATC &= ~(0x00c0); // clear !CS
LATC |= 0x0010; // !CS = 0, A0 = 0, R/!W = 0, E = 1
Nop8(); // 500ns delay
LATC ^= 0x0090; // !CS = 1, A0 = X, R/!W = 0, E = 0
//LATB &= ~(0x0FF0); // Clear LATB register
LATB &= ~(0x1FE0); // clear LATB
}
void LCDPositionCursor(unsigned int intHighAddress, unsigned int intLowAddress){
LCDCommandWrite(0x0460);
LCDDataWrite(intLowAddress);
LCDDataWrite(intHighAddress);
}
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.