LCDInfo.com

http://www.lcdinfo.com
It is currently Mon Nov 25, 2024 11:08

All times are UTC + 2 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri May 21, 2004 16:04 
Offline

Joined: Fri May 21, 2004 15:27
Posts: 4
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 :wink: 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--);   
}     

 



Top
 Profile  
 
 Post subject:
PostPosted: Sat May 22, 2004 17:38 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
I think you should check this piece of code
Code:
   //Set graphics area to 0x1E;
   statuscheck();
   P5 = 0x1e;
   writedatum();

   statuscheck();
   P5 = 0x00;
   writedatum();
   
   statuscheck();
   P5 = 0x40;
   writecommand();

especially the line P5 = 0x40

I think you should have 0x43 there.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 22, 2004 18:12 
Offline

Joined: Fri May 21, 2004 15:27
Posts: 4
:D THANX :D

Ohh man, I have checked the code several times. I am soo glade that you have found the mistake!!!

I will try it on monday and I hope that this was the only bug :roll:


Thanks

Jim


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 10:16 
Offline

Joined: Fri May 21, 2004 15:27
Posts: 4
Now everthing works fine! Thanks for your :lol: help :lol: !

But I have found a bug too in my code:

After the RAM delete I forgot to stop the auto increment mode. This cause the issue that a normal command won't be recognize like the address pointer set for the dipslay output. The following code segment shows the fixed version.

Code:

  //****clear RAM***************************
   //Auto inc on
   statuscheck();
   P5 = 0xb0;
   writecommand();

   
   for(i=0;i<8192;i++)
   {
   statuscheck_Automode();
   P5 = 0x00;
   writedatum();
   }

                //Auto inc off
   statuscheck();
   P5 = 0xb2;
   writecommand();

   //*****Text output on display*******   

   
   //Set address pointer
   statuscheck();
   P5 = 0x00;
   writedatum();

   statuscheck();
   P5 = 0x14;
   writedatum();

   statuscheck();
   P5 = 0x24;
   writecommand();
   
   //Auto inc on
   statuscheck();
   P5 = 0xb0;
   writecommand();

   for(m=0;m<3;m++)
   {
      for(i=0;i<10;i++)
      {
      statuscheck_Automode();
      P5 = Daten[i];
      writedatum();
      }
   }

                //Auto inc off
   statuscheck();
   P5 = 0xb2;
   writecommand();
      
   //Set Text on, Graphics off, Cursor off
   statuscheck();
   P5 = 0x94;
   writecommand();
   
   while(1);



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group