Graphical LCD ST7920 with 8051

Hello guys .. I've just bought a graphical lcd from Cytron on this link http://www.cytron.com.my/viewProduct.ph ... 8128x64%29
I have been trying to get it to work but it won't :S.. I went through the datasheet and interfaced it with AT89S51 in 8-bit parallel mode. Since I am not going to read from this lcd, I grounded the R/W pin and I also pulled RST and PSB pins to Vdd (5v).
I wrote the following code using Kiel .. it's pretty straight forward code. I just want to write anything to the graphical lcd. I am using 4.00 Mhz crystal.
I would love to know why it is not working. I hope I didn't leave anything vague .. thanks in advance for your help
..
I have been trying to get it to work but it won't :S.. I went through the datasheet and interfaced it with AT89S51 in 8-bit parallel mode. Since I am not going to read from this lcd, I grounded the R/W pin and I also pulled RST and PSB pins to Vdd (5v).
I wrote the following code using Kiel .. it's pretty straight forward code. I just want to write anything to the graphical lcd. I am using 4.00 Mhz crystal.
- CODE: SELECT_ALL_CODE
#include <reg51.h>
sbit LCD_RS = P1^0;
sbit LCD_E = P1^1;
#define LCD_PORT P0
void write_data (unsigned char);
void write_command (unsigned char);
void wait (unsigned char);
unsigned char code welcome[] = {"Welcome"};
void main ()
{
unsigned char size;
// Let's first initilize the LCD
wait(255);
write_command(0x30);
wait(140);
write_command(0x30);
wait(140);
// Display on off
write_command(0x0F);
wait(140);
// clear
write_command(0x01);
wait(140);
// Mode set
write_command(0x06);
wait(140);
// Cursor control
write_command(0x14);
wait(140);
// Now let's see if we can write WELCOME
while (1)
{
write_command(0x01);
wait(140);
write_command(0x02);
wait(140);
for (size= 0 ; size< 7 ; size++)
{
write_data(welcome[size]);
wait(140);
}
wait(140);
}
}
void write_data (unsigned char value)
{
LCD_RS = 1;
LCD_PORT = value;
LCD_E = 1;
LCD_E = 0;
}
void write_command (unsigned char value)
{
LCD_RS = 0;
LCD_PORT = value;
LCD_E = 1;
LCD_E = 0;
}
void wait (unsigned char delay)
{
unsigned char x,y;
for (x = 0 ; x< 254 ; x++)
{
for (y = 0 ; y < delay ; y++);
}
}
I would love to know why it is not working. I hope I didn't leave anything vague .. thanks in advance for your help
