LCDInfo.com

http://www.lcdinfo.com
It is currently Fri Nov 22, 2024 5:09

All times are UTC + 2 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: KS0108B Help please!
PostPosted: Mon Feb 10, 2003 3:54 
First, I've read almost every post in this group.

I'm interfacing a crystalfonts CFAG12864B unit to a PIC controller, I'll be ok if I can just get it off the ground. Can someone help me with what is required to initialize this display. What would help me the MOST would be some sort of suedo code like:

set cs1 high
wait 10ms
set D/I high
wait 5 ms
set data to databus 01110110
strobe E line etc, etc...

I've got the list of commands in the pdf file, it's the timing that has me thrown. Can anyone help, I'm really in a jam and this is important to me.

I'll post all my results for controlling with the PIC when finished.


Top
  
 
 Post subject:
PostPosted: Mon Feb 10, 2003 15:50 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
I'm not sure if I have already posted this somewhere but anyway this is what I've used:

The WriteData and WriteCommand functions should show what is needed to write data and commands to the display.
Code:
#define DISPLAY_ON         0x3f  //0011 1111
#define DISPLAY_OFF        0x3e  //0011 1110
#define DISPLAY_STARTLINE  0xc0  //1100 0000
#define DISPLAY_PAGE_SET   0xb8  //1011 1000
#define DISPLAY_COLUMN_SET 0x40  //0100 0000

void cKS0108::WriteCommand(unsigned char Command, unsigned char CS)
{
  Delay(delay);

  SetPortVal(CONTROL, ENABLE_LO | CS | RS_LO, 1);
  SetPortVal(DATA, Command, 1);
  SetPortVal(CONTROL, ENABLE_HI | CS | RS_LO, 1);
  Delay(delay);
  SetPortVal(CONTROL, ENABLE_LO | CS | RS_LO, 1);

  //SetPortVal(DATA, 0, 1);
}

void cKS0108::WriteData(const unsigned char Data[], unsigned int amount)
{
 unsigned char cs;
 unsigned int counter;
 for (counter=0; counter < amount;counter++)
 {
    cs = CurrentColumn>63?CS2:CS1;

    Delay(delay);
    SetPortVal(CONTROL, ENABLE_LO | cs | RS_HI, 1);
    SetPortVal(DATA, Data[counter], 1);
    SetPortVal(CONTROL, ENABLE_HI | cs | RS_HI, 1);
    Delay(delay);
    SetPortVal(CONTROL, ENABLE_LO | cs | RS_HI, 1);

    CurrentColumn++;
    if (CurrentColumn > 127)
       return;
 }
}

void cKS0108::SetColumn(unsigned char y)
{
  CurrentColumn = y;
  if (y < 64)
  {
     WriteCommand(DISPLAY_COLUMN_SET | (y&63), CS1);
     WriteCommand(DISPLAY_COLUMN_SET | 0, CS2);
  } else
  {
     WriteCommand(DISPLAY_COLUMN_SET | 63, CS1);
     WriteCommand(DISPLAY_COLUMN_SET | ((y-64)&63), CS2);
  }
}

void cKS0108::SetPage(unsigned char x)
{
  Delay(delay);
  WriteCommand(DISPLAY_PAGE_SET | x, CS1);
  WriteCommand(DISPLAY_PAGE_SET | x, CS2);
}

void cKS0108::SetStartLine(unsigned char line)
{
  WriteCommand(DISPLAY_STARTLINE | (line & 63), CS1);
  WriteCommand(DISPLAY_STARTLINE | (line & 63), CS2);
}

void cKS0108::InitLCD()
{
  unsigned char value;
  int x, a;
  value = 0x0;

  WriteCommand(DISPLAY_ON, CS1);
  WriteCommand(DISPLAY_ON, CS1);
  SetStartLine(0);

  for (x=0;x < 8;x++)
    {
      SetPage(x);SetColumn(0);
      for (a = 0 ;a < 128; a++)
      WriteData(&value, 1);
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 10, 2003 15:55 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
KS0108 timing:
Image

As you can see the timings in the code aren't exactly following the specs.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 11, 2003 5:30 
Thanks Henri:

Yes this will help, I found some other basic code. I can get 1/2 the display working both half work just not at the same time - I'll get it

Tnx again


Top
  
 
 Post subject: delay?
PostPosted: Tue Feb 25, 2003 7:14 
Hello,

I was wondering, how long does the delay need to be in between each write command?

I read somewhere in the driver that a delay of 30msec. is required. Is this correct ?


Thx.
Cheers,
Albert


Top
  
 
 Post subject: Re: delay?
PostPosted: Tue Feb 25, 2003 9:24 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
phileo wrote:
Hello,
I was wondering, how long does the delay need to be in between each write command?

I don't know what the exact delay should be as the timings I'm using aren't exactly following the specs anyway. But the picture in the earlier post has the timings information from the datasheet.

The delay function I've used should measure the time in microseconds but knowing Windows I don't really know what the real accuracy is. I've just used the fastest timing that has worked.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 26, 2003 19:41 
Offline

Joined: Wed Feb 26, 2003 19:36
Posts: 4
Location: Vancouver, Canada
Hello Henri,

Thanks for your response.

I am using a CrystalFontz CFAG12864B-TMI-V graphical LCD.
I have code which can successfully clear the display, but I have problems trying to display characters on the screen.

For example, when I display the letter "A", only the left half of the A comes out.

I am wondering if I need to change the delays in between each data write to the LCD ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 26, 2003 22:03 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Phileo wrote:
I am wondering if I need to change the delays in between each data write to the LCD ?

I noticed that for me a little delay was needed. But it was so little that using the delay function with value 0 worked.

Do you have any delay now ?


Top
 Profile  
 
 Post subject: got it!
PostPosted: Fri Feb 28, 2003 10:07 
Offline

Joined: Wed Feb 26, 2003 19:36
Posts: 4
Location: Vancouver, Canada
Hi Henri,

It turns out there was a bug with my code (I was using 16bit data type instead of 8bit data type for displaying characters).

I also did change the delays in between each write, and that improved the speed of the screen initialization

I can display a letter without problems now.


Thx.
Cheers,
Albert :D


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

All times are UTC + 2 hours


Who is online

Users browsing this forum: Google [Bot] and 24 guests


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:  
Powered by phpBB® Forum Software © phpBB Group