Hi!
I have a issue with my 240*128 Display. I have tryed to write a progamm which can display text on the display. I am using a 8 Bit 80C535 uC. Every thing works fine
the only issue that I have is the possision of the text on the LCD. E.g. I set up the Text Home address to 1400hex, initialize the address pointer to 1400hex and start writing text(10 characters) to the display in auto increment mode but they don't appear. When I fill the whole RAM than the text appears.
I think that my address pointer shows to the wrong address. But I have no idea why
.
I hope you understand my issue!!
THANX for your help
Jim
Code:
#include <REG515.H>
/* P3 is connected to a LED Bar to visualise the current LCD status
P4 and P5 ist connected with the LCD
*/
void writedatum(void);
void writecommand(void);
void delay(unsigned int zeit);
void statuscheck(void);
void statuscheck_Automode(void);
sbit RST = P4^1; //Reset low aktiv
sbit CD = P4^2; //CD=0 Datenregister CD=1 StatusCommandregister
sbit CE = P4^3; //Display Enable low aktiv
sbit R_D = P4^4; //Display read low aktiv
sbit W_R = P4^5; //Display write low aktiv
int i,n;
unsigned char LCD_Status;
unsigned char Daten[10] = {0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x3a};
void main()
{
//Reset
P3 = 0x00;
RST = 0;
delay(5000);
RST = 1;
statuscheck();
//Set graphics home adresse to 0x0000
statuscheck();
P5 = 0x00;
writedatum();
statuscheck();
P5 = 0x00;
writedatum();
statuscheck();
P5 = 0x42;
writecommand();
//Set text home address to 0x1400
statuscheck();
P5 = 0x00;
writedatum();
statuscheck();
P5 = 0x14;
writedatum();
statuscheck();
P5 = 0x40;
writecommand();
//Set graphics area to 0x1E;
statuscheck();
P5 = 0x1e;
writedatum();
statuscheck();
P5 = 0x00;
writedatum();
statuscheck();
P5 = 0x40;
writecommand();
//Set text area to 0x1E;
statuscheck();
P5 = 0x1e;
writedatum();
statuscheck();
P5 = 0x00;
writedatum();
statuscheck();
P5 = 0x41;
writecommand();
//Set OR mode
statuscheck();
P5 = 0x80;
writecommand();
//Set address pointer
statuscheck();
P5 = 0x00;
writedatum();
statuscheck();
P5 = 0x00;
writedatum();
statuscheck();
P5 = 0x24;
writecommand();
//****Delet Display RAM***************************
//Auto inc on
statuscheck();
P5 = 0xb0;
writecommand();
for(i=0;i<8192;i++)
{
statuscheck_Automode();
P5 = 0x00;
writedatum();
}
//*****Send data to display*******
//Set Text on, Graphics off, Cursor off
statuscheck();
P5 = 0x94;
writecommand();
//Set address pointer
statuscheck();
P5 = 0x00;
writedatum();
statuscheck();
P5 = 0x14;
writedatum();
statuscheck();
P5 = 0x24;
writecommand();
for(n=0;n<819;n++)
{
for(i=0;i<10;i++)
{
statuscheck_Automode();
P5 = Daten[i];
writedatum();
}
}
while(1);
}
//**********Functionen*****************
void statuscheck(void)
{
do {
P5 = 0xff; //P5 must be set high because the LCD can only pull it to low
CD = 1;
R_D = 0;
CE = 0;
delay(5);
LCD_Status = P5;
CE = 1;
R_D = 1;
LCD_Status &= 0x03;
P3 = LCD_Status;
} while (LCD_Status != 0x03);
}
void statuscheck_Automode(void)
{
do {
P5 = 0xff; //P5 must be set high because the LCD can only pull it to low
CD = 1;
R_D = 0;
CE = 0;
delay(5);
LCD_Status = P5;
CE = 1;
R_D = 1;
LCD_Status &= 0x08;
P3 = LCD_Status;
} while (LCD_Status != 0x08);
}
void writedatum (void)
{
CD = 0;
W_R = 0;
CE = 0;
delay(5);
CE = 1;
W_R = 1;
CD = 1;
}
void writecommand (void)
{
CD = 1;
W_R = 0;
CE = 0;
delay(5);
CE = 1;
W_R = 1;
CD = 1;
}
void delay(unsigned int zeit)
{
for (; zeit >0; zeit--);
}