Hello Friends
I learnt hardware interfacing of JHD12864E with AT89C51 Microcontroller in my previous thread. I flashed sample program into AT89c51. Sample program was working fine with GLCD. I am trying to print message on GLCD. I wrote program in c language without compiler error. When I flashed my program it's working with GLCD. I am sure about the all connection, it's look like correct because sample program is working with no problem.
I am thinking the problem is only in program code. I hope someone will help..
I learnt hardware interfacing of JHD12864E with AT89C51 Microcontroller in my previous thread. I flashed sample program into AT89c51. Sample program was working fine with GLCD. I am trying to print message on GLCD. I wrote program in c language without compiler error. When I flashed my program it's working with GLCD. I am sure about the all connection, it's look like correct because sample program is working with no problem.
I am thinking the problem is only in program code. I hope someone will help..
C:
#include<reg51.h>
#define GlcdDataBus P2 //Data pins of GLCD connected to port P2
sbit RS = P3^0; // RS pin of GLCD connected to port P3.0
sbit RW = P3^1; // RW pin of GLCD connected to port P3.1
sbit EN = P3^2; // E pin of GLCD connected to port P3.2
sbit CS1 = P3^3; // CS1 pin of GLCD connected to port P3.3
sbit CS2 = P3^4; // CS2 pin of GLCD connected to port P3.4
/*function to generate Delay */
void Delay(int count)
{
int i;
for(i = 0; i < count; i++);
}
/* Function to send the command to LCD */
void Glcd_Command(char cmd)
{
GlcdDataBus = cmd; //Send the Command
RS = 0; // Send LOW pulse on RS pin for selecting Command register
RW = 0; // Send LOW pulse on RW pin for Write operation
EN = 1; // Generate a High-to-low pulse on EN pin
Delay(100);
EN = 0;
Delay(1000);
}
/* Function to send the data to LCD */
void Glcd_Data(char dat)
{
GlcdDataBus = dat; //Send the data on DataBus
RS = 1; // Send HIGH pulse on RS pin for selecting data register
RW = 0; // Send LOW pulse on RW pin for Write operation
EN = 1; // Generate a High-to-low pulse on EN pin
Delay(100);
EN = 0;
Delay(1000);
}
/*Function to send string to LCD*/
void GlcdData_String(unsigned char *string)
{
int index=0;
while(string[index]!='\0')
{
Glcd_Data(string[index]);
index++;
Delay(10);
}
}
void Glcd_SelectPage0() // CS1=1, CS2=0
{
CS1 = 1;
CS2 = 0;
}
void Glcd_SelectPage1() // CS1=0, CS1=1
{
CS1 = 0;
CS2 = 1;
}
void main(void)
{
unsigned char message[] ="Hello World!";
/* Select the Page0/Page1 and Turn on the GLCD */
Glcd_SelectPage0();
Glcd_Command(0x3f);
Glcd_SelectPage1();
Glcd_Command(0x3f);
Delay(100);
/* Select the Page0/Page1 and Enable the GLCD */
Glcd_SelectPage0();
Glcd_Command(0xc0);
Glcd_SelectPage1();
Glcd_Command(0xc0);
Delay(100);
Glcd_SelectPage0(); // Display HELLO World! on Page0, Line1
Glcd_Command(0xb8);
GlcdData_String(message);
}