Hello, I have been working on a side project for the last few weeks that includes integrating a 240x128 LCD. I am having issues getting anything to show up despite trying what some of the other posts on this forum suggested, as well as using the WinTest program as a template. I am using a C8051F132 uC, from SiLabs. I have not touched the contrast control since for whatever reason a pot isn't included with this display. I'm pretty sure contrast isn't a problem, since I see the random lines during the hardware reset. Below is the applicable part of my code:
I added the "Delay(10)" line to the data/command write routines after reading a recommendation to use delays instead of polling the busy flag. Using the debug tool in my Keil compiler, I am able to see that the status read comes back with a value of 0xA3, which seems to make sense. Any advice would be MUCH appreciated, I'm out of ideas!
~Dustin
Code:
#include <gui.h>
#define LcmLengthDots 240
#define LcmWidthDots 128
void Read_LCD(void);
void DataW_LCD(int dval);
void ComW_LCD(int dval);
/*
sbit WR = P5^6;
sbit RD = P5^5;
sbit CD = P5^4;
sbit RESET = P5^3;
sbit FS = P5^2;
sbit CE = P5^1;
sbit P63 = P5^7; - having an issue with pin P6.3, P5.7 is used as a replacement
*/
void Gui_Init(void)
{
FS = 0;
RESET = 0;
Delay(1);
RESET = 1;
Read_LCD();
DataW_LCD(0x00);
Read_LCD();
DataW_LCD(0x00);
Read_LCD();
ComW_LCD(0x40);
Read_LCD();
DataW_LCD(0x1E);
Read_LCD();
DataW_LCD(0x00);
Read_LCD();
ComW_LCD(0x41);
Read_LCD();
DataW_LCD(0x24);
Read_LCD();
DataW_LCD(0x03);
Read_LCD();
ComW_LCD(0x21);
Read_LCD();
ComW_LCD(0xA7);
Read_LCD();
ComW_LCD(0x81);
Read_LCD();
ComW_LCD(0x97);
Read_LCD();
ComW_LCD(0x97);
Read_LCD();
ComW_LCD(0x97);
}
void ComW_LCD(int dval)
{
P6 = dval;
if(dval & 0x08)
{
P63 = 1;
}
CD = 1;
CE = 0;
WR = 0;
RD = 1;
Delay(1);
CE = 1;
P6 = 0x00;
P63 = 0;
Delay(10);
}
void DataW_LCD(int dval)
{
P6 = dval;
if(dval & 0x08)
{
P63 = 1;
}
CD = 0;
CE = 0;
WR = 0;
RD = 1;
Delay(1);
CE = 1;
P6 = 0x00;
P63 = 0;
Delay(10);
}
void Read_LCD(void)
{
bit read = 0;
int val;
P6MDOUT = 0x00;
P5MDOUT &= ~0x80;
P6 = 0xFF;
P63 = 1;
CD = 1;
RD = 0;
WR = 1;
while(!read)
{
CE = 0;
Delay(1);
val = P6;
read = ((val & 0x03) == 0x03);
CE = 1;
}
P6MDOUT = 0xFF;
P5MDOUT |= 0xFE;
P6 = 0x00;
P63 = 0;
}
~Dustin
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.